Last active
April 25, 2016 18:07
-
-
Save jkinkead/d49085fe52d1d25d15557f6c77cec283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Example { | |
val seq = Seq(1, 2, 3) | |
/////////// | |
// RIGHT // | |
/////////// | |
// You can either use parens: | |
val parens: Seq[Double] = seq.map(value => value + 1).map(value => value / 1.0) | |
// Or braces, which can look nicer for multi-line expressions: | |
val braces: Seq[Double] = seq.map { value => | |
value + 1 | |
}.map { value => | |
value / 1.0 | |
} | |
/////////// | |
// WRONG // | |
/////////// | |
// Don't infix (call without a `.`). | |
val infix: Seq[Double] = seq map { value => | |
value + 1 | |
} map { value => | |
value / 1.0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment