Skip to content

Commit

Permalink
Gave Option its own nonEmpty.
Browse files Browse the repository at this point in the history
A bit further down Option's slippery slope of collections methods, but
those sudden implicit conversions to Iterable are legitimately annoying.
  • Loading branch information
paulp committed Dec 6, 2011
1 parent 526c086 commit 001710d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/library/scala/Option.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ sealed abstract class Option[+A] extends Product with Serializable {
@inline final def filterNot(p: A => Boolean): Option[A] =
if (isEmpty || !p(this.get)) this else None

/** Returns false if the option is $none, true otherwise.
* @note Implemented here to avoid the implicit conversion to Iterable.
*/
final def nonEmpty = isDefined

/** Necessary to keep $option from being implicitly converted to
* [[scala.collection.Iterable]] in `for` comprehensions.
*/
Expand Down

0 comments on commit 001710d

Please sign in to comment.