Skip to content

Instantly share code, notes, and snippets.

@zcox
Last active December 24, 2015 16:28
Show Gist options
  • Select an option

  • Save zcox/6827796 to your computer and use it in GitHub Desktop.

Select an option

Save zcox/6827796 to your computer and use it in GitHub Desktop.
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