Scala Wonderland: All operations are method calls
Iāve started learning Scala two months ago and I canāt get back to Murakamiās 1Q84 so exciting it is. In the coming series Iād like to share my excitement with you. It wonāt be yet another step-by-step tutorial. Iāll share features that made me think (IBM should be proud of me). For whatever reason.
val i = 1 + 2
⦠is equal to ā¦
val i = (1).+(2)
Scala doesnāt have operators. It has methods with names like +, -, *, / instead. The code above invokes method named ā+ā on the object Int representing number 1 passing Int object of value 2 as an argument.
Note that you donāt have to type ā.ā to ivoke a method on an object and also you donāt need to provide parentheses around method arguments. This knowledge helps a lot when trying to understand what is a program written in Scala actually doing.
Stay tuned!




