Option

scala.Option
See theOption companion class
object Option

Attributes

Companion
class
Source
Option.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Option.type

Members list

Value members

Concrete methods

def apply[A](x: A | Null): Option[A]

An Option factory which creates Some(x) if the argument is not null, and None if it is null.

An Option factory which creates Some(x) if the argument is not null, and None if it is null.

Type parameters

A

the type of the value

Value parameters

x

the value

Attributes

Returns

Some(value) if value != null, None if value == null

Source
Option.scala
def empty[A]: Option[A]

An Option factory which returns None in a manner consistent with the collections hierarchy.

An Option factory which returns None in a manner consistent with the collections hierarchy.

Type parameters

A

the type of the option's value

Attributes

Source
Option.scala
def unless[A](cond: Boolean)(a: => A): Option[A]

Unless a given condition is true, this will evaluate the a argument and return Some(a). Otherwise, a is not evaluated and None is returned.

Unless a given condition is true, this will evaluate the a argument and return Some(a). Otherwise, a is not evaluated and None is returned.

Type parameters

A

the type of the value

Value parameters

a

the value to wrap in Some when cond is false (evaluated lazily)

cond

the condition to evaluate

Attributes

Source
Option.scala
def when[A](cond: Boolean)(a: => A): Option[A]

When a given condition is true, evaluates the a argument and returns Some(a). When the condition is false, a is not evaluated and None is returned.

When a given condition is true, evaluates the a argument and returns Some(a). When the condition is false, a is not evaluated and None is returned.

Type parameters

A

the type of the value

Value parameters

a

the value to wrap in Some when cond is true (evaluated lazily)

cond

the condition to evaluate

Attributes

Source
Option.scala

Implicits

Implicits

implicit def option2Iterable[A](xo: Option[A]): Iterable[A]

An implicit conversion that converts an option to an iterable value.

An implicit conversion that converts an option to an iterable value.

Type parameters

A

the element type of the option

Value parameters

xo

the option to convert to an iterable

Attributes

Source
Option.scala