flatMap

func flatMap<T, U>(_: T?, f: @noescape (T) -> U?)

Returns f(self)! iff self and f(self) are not nil.

Declaration

func flatMap<T, U>(x: T?, f: @noescape (T) -> U?) -> U?
func flatMap<C : CollectionType, T>(_: C, transform: (C.Generator.Element) -> [T])

Return an Array containing the results of mapping transform over source and flattening the result.

Declaration

func flatMap<C : CollectionType, T>(source: C, transform: (C.Generator.Element) -> [T]) -> [T]
func flatMap<S : SequenceType, T>(_: S, transform: @noescape (S.Generator.Element) -> [T])

Return an Array containing the results of mapping transform over source and flattening the result.

Declaration

func flatMap<S : SequenceType, T>(source: S, transform: @noescape (S.Generator.Element) -> [T]) -> [T]