Last active
August 29, 2015 14:04
-
-
Save kscaldef/003f0d9a198d6e7ccf24 to your computer and use it in GitHub Desktop.
Seq WTF?
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
scala> val things: Seq[String] = Seq("asdf") | |
things: Seq[String] = List(asdf) | |
scala> things match { case hd :: tl => "not empty" ; case Nil => "empty" } | |
res1: String = not empty | |
scala> val things: Seq[String] = scala.collection.mutable.ArrayBuffer("asdf") | |
things: Seq[String] = ArrayBuffer(asdf) | |
scala> things match { case hd :: tl => "not empty" ; case Nil => "empty" } | |
scala.MatchError: ArrayBuffer(asdf) (of class scala.collection.mutable.ArrayBuffer) | |
... | |
scala> Set(1,2,3) | |
res4: scala.collection.immutable.Set[Int] = Set(1, 2, 3) | |
scala> Set(1,2,3).toSeq | |
res5: Seq[Int] = ArrayBuffer(1, 2, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment