How can I pattern match on a range in Scala? - Stack Overflow

PHOTO EMBED

Fri Feb 25 2022 21:48:18 GMT+0000 (UTC)

Saved by @joel113 #scala

n match {
  case it if 0 until 5 contains it  => "less than five"
  case it if 5 until 10 contains it => "less than ten"
  case _ => "a lot"
}
content_copyCOPY

https://stackoverflow.com/questions/3160888/how-can-i-pattern-match-on-a-range-in-scala