【发布时间】:2011-03-10 19:22:17
【问题描述】:
在 Ruby 中我可以这样写:
case n
when 0...5 then "less than five"
when 5...10 then "less than ten"
else "a lot"
end
如何在 Scala 中做到这一点?
编辑:最好比使用if 更优雅。
【问题讨论】:
-
查看相关的 stackoverflow 问题:Can a range be matched in Scala?
标签: scala pattern-matching range