Core concept
val abs = if (n >= 0) n else -n
val doubled = for (i <- 1 to 10) yield i * 2Advertisement
How it works
if without else evaluates to Unit. for-yield generates collection.
Advertisement
Trade-offs + gotchas
Idiomatic FP-first style.