Use type of “Any” carefully in Scala

Think about the code below:

I intent to see the compiler error for second ‘increment’ int the first place. But it don’t, the compiler report ok and the output of the program is:

The compiler recognize the three arguments “world”, “6”, “7” as a tuple of (“world”, 6, 7). So the correct type of arugment for function ‘increment’ should be ‘String’:

Leave a Reply

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

*
*