Last active
February 26, 2021 20:50
-
-
Save deanwampler/c08722400ecb25e74d4ee6ee3048b4b2 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
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