Home » JVM Languages » Scala » Scala Wonderland: All operations are method calls

About Rado Buransky

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!
 

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

and many more ....

Leave a Reply

Your email address will not be published. Required fields are marked *

*


6 × seven =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close