Here's a bit of Scala code to sum the values from 1 to 9 which are divisible by 3 or 5. Why does line 5 return a Unit and not a Boolean type?
object Sample {
def main(args : Array[String]) {
val answer = (1 until 10).foldLeft(0) ((result, current) => {
if ((current % 3 == 0) || (current % 5 == 0)) {
result + current
}
})
println(answer)
}
}