Higher order functions

What? Functions you can pass as arguments to other functions. Such as map, filter, reduce, flatMap.

  • map – operate on each element in the collection (then return a new collection).
  • filter – return a subset of the collection that satisfies some condition. 
  • reduce – combine and return a single value. 
  • flatMap – flatten a collection of collections into a collection. 

lazy var

What? The vars that are marked lazy won’t be initialized until it’s used the first time.
When to use, if the var is a view? 

  • When the view has a good chance of never needed based on the condition. e.g., views in a collapsible panel. 
  • When the view isn’t needed before user interaction starts. Such as off-screen views, or views can be shown with delay.