Monday 21 September 2020

Scala: Operators are methods

Operators are modelled as methods in Scala.

For example,

1 + 10 is same as 1.+(10)

scala> 1 + 10
val res41: Int = 11

scala> 1.+(10)
val res42: Int = 11

Find some more examples below.

scala> "hello" * 3
val res43: String = hellohellohello

scala> "hello".*(3)
val res44: String = hellohellohello




 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment