Skip to content

Instantly share code, notes, and snippets.

@jkinkead
Last active April 25, 2016 18:07
Show Gist options
  • Save jkinkead/d49085fe52d1d25d15557f6c77cec283 to your computer and use it in GitHub Desktop.
Save jkinkead/d49085fe52d1d25d15557f6c77cec283 to your computer and use it in GitHub Desktop.
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