尝试使用Scala 2.10.3'条件'语句:
scala> val index = "male-names"
index: String = male-names
scala> val kind = if (index == "male-mames") "mn" else "fn"
kind: String = fn
为什么'善'得到“fn”而不是“mn”?
另一方面,以下情况仍然存在:
scala> index == "male-names"
res28: Boolean = true
scala> index
res29: String = male-names
答案 0 :(得分:1)
scala> val index = "male-names"
index: String = male-names
有一点拼写错误
scala> val kind = if (index == "male-mames") "mn" else "fn"
^
kind: String = fn