Permalink
Browse files

Gave Option its own nonEmpty.

A bit further down Option's slippery slope of collections methods, but
those sudden implicit conversions to Iterable are legitimately annoying.
  • Loading branch information...
1 parent 526c086 commit 001710d73eedbe3f23b7d704c772a8616ddf2f10 @paulp paulp committed Dec 6, 2011
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/library/scala/Option.scala
@@ -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.
*/

0 comments on commit 001710d

Please sign in to comment.