diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-02 16:26:05 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-02 16:26:05 +0000 |
commit | 8eee4372898062118479326639f6a4e950d0cb79 (patch) | |
tree | bbc2fa3a68ca5f514bd52c39aa9676fc121f39c7 | |
parent | 328651c39a3d35a2aaa0e09e7bb7a59bfddf90b3 (diff) | |
download | scala-8eee4372898062118479326639f6a4e950d0cb79.tar.gz scala-8eee4372898062118479326639f6a4e950d0cb79.tar.bz2 scala-8eee4372898062118479326639f6a4e950d0cb79.zip |
Option gets an empty factory like the collections.
-rw-r--r-- | src/library/scala/Option.scala | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 8992024353..c3cfb14b73 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -6,12 +6,9 @@ ** |/ ** \* */ - - package scala -object Option -{ +object Option { /** An implicit conversion that converts an option to an iterable value */ implicit def option2Iterable[A](xo: Option[A]): Iterable[A] = xo.toList @@ -23,6 +20,11 @@ object Option * @return Some(value) if value != null, None if value == null */ def apply[A](x: A): Option[A] = if (x == null) None else Some(x) + + /** An Option factory which returns None in a manner consistent with + * the collections hierarchy. + */ + def empty[A] : Option[A] = None } /** This class represents optional values. Instances of <code>Option</code> |