summaryrefslogtreecommitdiff
path: root/src/library/scala/Option.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-12-06 14:25:49 -0800
committerPaul Phillips <paulp@improving.org>2011-12-06 14:27:51 -0800
commit001710d73eedbe3f23b7d704c772a8616ddf2f10 (patch)
tree06adf4cb571439a9d85e8ffbc9164cfd14daeb5c /src/library/scala/Option.scala
parent526c086e121d8d6c15726c769edbf96efd882ae7 (diff)
downloadscala-001710d73eedbe3f23b7d704c772a8616ddf2f10.tar.gz
scala-001710d73eedbe3f23b7d704c772a8616ddf2f10.tar.bz2
scala-001710d73eedbe3f23b7d704c772a8616ddf2f10.zip
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.
Diffstat (limited to 'src/library/scala/Option.scala')
-rw-r--r--src/library/scala/Option.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index c1b64808b0..bd498de847 100644
--- a/src/library/scala/Option.scala
+++ b/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.
*/