Last active
December 24, 2015 16:28
-
-
Save zcox/6827796 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| scala> val m = Map("a" -> 1, "b" -> 2) | |
| m: scala.collection.immutable.Map[String,Int] = Map(a -> 1, b -> 2) | |
| type StringIntMap = scala.collection.immutable.Map[String, Int] | |
| val m: StringIntMap = Map("a" -> 1) | |
| val m: Map[String, Int] = Map[String, Int]("a" -> 1) | |
| val m: Map[String, Int] = Map("a" -> 1) | |
| val m = Map[String, Int]("a" -> 1) | |
| val m = Map("a" -> 1) | |
| object O { def apply(s: String) = s } | |
| O("hi") | |
| class C { def apply(s: String) = s } | |
| val c = new C | |
| c("hi") | |
| def f(xs: String*) { /*xs: Seq[String] */ } | |
| f() | |
| f("a") | |
| f("a", "b") | |
| ("a", 1) == new Tuple2("a", 1) | |
| "a" -> 1 == new Tuple2("a", 1) | |
| class MyInt(x: Int) { | |
| def plus(y: Int) = new MyInt(x + y) | |
| def +(y: Int) = plus(y) | |
| } | |
| new MyInt(1).plus(2) | |
| new MyInt(1) + 2 | |
| "a".->(1) == "a" -> 1 | |
| val m = Map("a" -> 1, "b" -> 2) | |
| val m: scala.collection.immutable.Map[String, Int] = | |
| scala.collection.immutable.Map.apply[String, Int]( | |
| new scala.Tuple2[String, Int]("a", 1), | |
| new scala.Tuple2[String, Int]("b", 2)) | |
| val g = Graph("a" --> "b", "b" --> "c") | |
| val g = Graph("a" -- 1 --> "b", "b" -- 2 --> "c") | |
| val g = Graph("a" -- 1 --> "b", "b" --> "c") | |
| def readFirstLineFromFile(path: String): String = | |
| using(new BufferedReader(new FileReader(path)))(_.readLine()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment