Skip to content

Instantly share code, notes, and snippets.

@kscaldef
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kscaldef/003f0d9a198d6e7ccf24 to your computer and use it in GitHub Desktop.
Save kscaldef/003f0d9a198d6e7ccf24 to your computer and use it in GitHub Desktop.
Seq WTF?
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