From 8eee4372898062118479326639f6a4e950d0cb79 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 2 Jul 2010 16:26:05 +0000 Subject: Option gets an empty factory like the collections. --- src/library/scala/Option.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/library') 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 Option -- cgit v1.2.3