Closed valydia closed 6 years ago
You can also note the +:
extractor for Seq
:
val xs = Seq.range(0, 10)
xs match {
case head +: tail => println(head)
case _ => println("meh")
}
Also, head
is defined on GenTraversable
, so you might want to widen the scope.
IMO most people don't know of GenTraversable
.
I did not even know of the +:
extractor, never used it 😲
Thanks @wookietreiber , I've added an example with the extractor +:
LGTM.
Thanks for the feedbacks! I removed the alternative using the extractor +:
👍
Hello there! Is there anything on my end that I can do to help this PR being merged?
This should be merged
Fixes https://github.com/alexandru/scala-best-practices/issues/50