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
val list = "Hello, Scala".toList //> list : List[Char] = List(H, e, l, l, o, ,, , S, c, a, l, a) | |
list.foreach(print(_)) //> Hello, Scala | |
println //> |
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 |
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 { | |
val immutable: String = "Hello, Scala" //> immutable : String = Hello, Scala | |
var mutable = immutable //> mutable : String = Hello, Scala | |
mutable = "Hello, Hacker" | |
println(mutable) //> Hello, Hacker | |
} |
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 { | |
val i = 0 //> i : Int = 0 | |
val scope = "outer scope" //> scope : String = outer scope | |
if (i == 0) { | |
val scope = "inner scope" | |
println(scope + ": " + i) | |
} //> inner scope: 0 | |
} |
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 { | |
var a = 0 //> a : Int = 0 | |
if (a < 10) a = a + 1 | |
println(a) //> 1 | |
if (a < 10) a = a + | |
1 | |
println(a) //> 2 | |
} |
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 { | |
var a = 0 //> a : Int = 0 | |
if (a < 10) a = a + 1 | |
println(a) //> 1 | |
if (a < 10) a = a | |
+ 1 //> res0: Int = 1 | |
println(a) //> 1 | |
} |
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 { | |
var a = 0 //> a : Int = 0 | |
if (a < 10) a = a + 1 | |
println(a) //> 1 | |
if (a < 10) a = (a | |
+ 1) | |
println(a) //> 2 | |
} |
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 { | |
var a = 0 //> a : Int = 0 | |
if (a < 10) a = a + 1 | |
println(a) //> 1 | |
if (a < 10) { | |
a = a + 1 | |
} | |
println(a) //> 2 | |
} |
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 { | |
var a = 0 //> a : Int = 0 | |
if (a < 10) a = a + 1 | |
println(a) //> 1 | |
if (a < 10) a = { | |
println("before: " + a) | |
a + 1 | |
} //> before: 1 | |
println("after: " + a) //> after: 2 |
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 { | |
class ScalaFun | |
new ScalaFun() //> res0: ScalaHackSession.ScalaFun = ScalaHackSession$ScalaFun@1f7ebc89 | |
new ScalaFun //> res1: ScalaHackSession.ScalaFun = ScalaHackSession$ScalaFun@b886fb3 | |
} |
OlderNewer