Scala Examples: Difference between revisions
Jump to navigation
Jump to search
Hoppinglife (talk | contribs) Created page with "== Pattern Matching on Seq == <pre class="hljs"> def f(ints: Seq[Int]): String = ints match { case Seq() => "The Seq is empty !" case Seq(first) => s"The seq..." |
Hoppinglife (talk | contribs) |
||
| Line 1: | Line 1: | ||
== Pattern Matching on Seq == | == Pattern Matching on Seq == | ||
< | <syntaxhighlight lang="scala"> | ||
def f(ints: Seq[Int]): String = ints match { | def f(ints: Seq[Int]): String = ints match { | ||
case Seq() => | case Seq() => | ||
| Line 30: | Line 31: | ||
"The seq didn't match any of the above, so it must be empty" | "The seq didn't match any of the above, so it must be empty" | ||
} | } | ||
</ | |||
</synctaxhighlight> | |||