Monday 21 September 2020

Scala: Method without parameters do not require () while calling

 For example, length() method of string can be called without parameters.

scala> "Hello".length
val res45: Int = 5

If you like to use (), you can do so.

scala> "Hello".length()
val res46: Int = 5

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment