Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/14332#discussion_r71993270
--- Diff:
examples/src/main/scala/org/apache/spark/examples/ml/DataFrameExample.scala ---
@@ -54,14 +54,13 @@ object DataFrameExample {
}
}
- parser.parse(args, defaultParams).map { params =>
- run(params)
- }.getOrElse {
- sys.exit(1)
+ parser.parse(args, defaultParams) match {
+ case Some(params) => run(params)
+ case _ => sys.exit(1)
}
--- End diff --
The issue here is `map`. On style: why would you use `map` with an
expression whose type is `Unit`? theoretically that's never correct. (It's a
warning in IJ.) The question isn't readability.
The deeper issue turns up with view-like collections, where the `map` body
won't actually execute at all. I don't know if that type of problem is actually
possible with `Option` though. I figured it can't hurt to foreclose that
possibility entirely with a more explicit construct.
`fold` is less obvious and has the same theoretical problem. I would not
use that pattern.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]