4 notes

Some ways to write function literals in Scala

Just cuz iheardata asked and I can’t find a set of examples I like.

(i: Int) => i + 1

{ (i) => i + 1 }       : (Int => Int)
( (i) => i + 1 )       : (Int => Int)
{ i => i + 1 }         : (Int => Int)
( i => i + 1 )         : (Int => Int)
{ _ + 1 }              : (Int => Int)
( _ + 1 )              : (Int => Int)

(_: Int) + 1
  1. asoftsea reblogged this from coderspiel
  2. coderspiel posted this

}

blog comments powered by Disqus