Fresh Swift
  • About
  • Tags
Fresh Swift

#flatmap


Optionals as Collections

Joshua Emmons returns to a post he wrote on dealing with optionals and failable initializers. Joshua goes back to basics, looking at how flapMap applies to optionals, and comes to realise that when we think of optionals as collections, things make more sense.

Posted on April 8, 2018

#optional  #flatmap 

Optional Forward Application

This is an interesting post from Joshua Emmons in which he looks at handling optional parameters when using failable initialisers. Joshua initially described an approach using a custom free function, before amending the post to recommend using the flatMap function available in the Swift standard library.

Posted on April 1, 2018

#optional  #flatmap 

An aside about flatMap and monads

This is a very interesting article from Matt Gallagher in which he discusses monads in the context of Swift and it’s flatmap functions. If you are not too familiar with the Haskell programming language, and the concept of a monad, this is a great place to start learning.

Posted on July 11, 2017

#flatmap  #monad 

Swift Tricks: Searching for Objects by Type

Performing operations such as map or flatmap on large collections can be expensive. Luckily, Swift provides lazy collections. Using a lazy collection, all operations are delayed until we actually need to access an element. In this post, TIm Ekl uses a lazy collection together with flatmap to efficiently find a specific type in an array of types.

Posted on May 24, 2017

#lazycollection  #flatmap 

 •  2021  •  Fresh Swift

Hugo v0.81.0 powered  •  Theme by Beautiful Jekyll adapted to Beautiful Hugo