Last active
August 29, 2015 13:57
-
-
Save taitruong/9465189 to your computer and use it in GitHub Desktop.
infix, prefix, and postfix operators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object ScalaHackSession { | |
//method calls instead of infix operators | |
(1).+(1) //> res0: Int(2) = 2 | |
1. + (1) //> res1: Double(2.0) = 2.0 | |
"Hello, Scala".indexOf("a") //> res2: Int = 9 | |
"Hello, Scala".indexOf("a", 10) //> res3: Int = 11 | |
//method calls instead of unary prefix operators | |
true.unary_! //> res4: Boolean = false | |
(1 - 2).unary_+ //> res5: Int = -1 | |
(1 - 2).unary_- //> res6: Int = 1 | |
//method call instead of unary postfix operator | |
"Hello, Scala".toLowerCase //> res7: String = hello, scala | |
"Hello, Scala".toUpperCase //> res8: String = HELLO, SCALA | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment