diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-03 11:11:45 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-03 11:11:45 -0800 |
commit | d188f6fdded6fdd9df3960d6085b9b80046c05ca (patch) | |
tree | 7389f7a3541e78f45f54eb60b6088eb03ce1f8ef /src/library | |
parent | 45a26ce3102f54e4f72165aef42fab7f73681c1d (diff) | |
download | scala-d188f6fdded6fdd9df3960d6085b9b80046c05ca.tar.gz scala-d188f6fdded6fdd9df3960d6085b9b80046c05ca.tar.bz2 scala-d188f6fdded6fdd9df3960d6085b9b80046c05ca.zip |
Added forall to Option.
Another salvo in the war against option2Iterable.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Option.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index bd498de847..6db4904b93 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -192,6 +192,13 @@ sealed abstract class Option[+A] extends Product with Serializable { @inline final def exists(p: A => Boolean): Boolean = !isEmpty && p(this.get) + /** Returns true if this option is empty '''or''' the predicate + * $p returns true when applied to this $option's value. + * + * @param p the predicate to test + */ + @inline final def forall(p: A => Boolean): Boolean = isEmpty || p(this.get) + /** Apply the given procedure $f to the option's value, * if it is nonempty. Otherwise, do nothing. * |