Thursday, September 15, 2016

Postfix Operator Example...

#124
scala> val str = "Physics, Maths"
str: String = Physics, Maths

scala> val res = str.toUpperCase()
res: String = PHYSICS, MATHS

scala> val res = str.toUpperCase
res: String = PHYSICS, MATHS

scala> val res = str toUpperCase
:25: warning: postfix operator toUpperCase should be enabled
by making the implicit value scala.language.postfixOps visible.
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scaladoc for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
       val res = str toUpperCase
                     ^
res: String = PHYSICS, MATHS