Skip to content

Instantly share code, notes, and snippets.

@deanwampler
Last active February 26, 2021 20:50
Show Gist options
  • Save deanwampler/c08722400ecb25e74d4ee6ee3048b4b2 to your computer and use it in GitHub Desktop.
Save deanwampler/c08722400ecb25e74d4ee6ee3048b4b2 to your computer and use it in GitHub Desktop.
def count[T](ts: T*): Int = ts.size
val seq = Seq(1,2,3)
count(seq) // Returns 1!
count(seq*) // Returns 3. Use seq* instead of seq: _*
Seq('a', 'b', 'c', 'd', 'e') match {
case Seq('a', tail*) => s"Found a, $tail" // Instead of Seq('a', tail: _*)
case Seq('b', _*) => "Found b" // Instead of Seq('a', _: _*)
case seq => s"Other list: $seq"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment