我可以“屈服”成地图吗?我可以使用for-comprehenion/yield在Scala中创建地图吗?
我已经试过
val rndTrans = for (s1 <- 0 to nStates;
s2 <- 0 to nStates
if rnd.nextDouble() < trans_probability)
yield (s1 -> s2);
(与,
代替->
),但我得到的错误
TestCaseGenerator.scala:42: error: type mismatch;
found : Seq.Projection[(Int, Int)]
required: Map[State,State]
new LTS(rndTrans, rndLabeling)
我明白为什么,但我看不出如何解决这个: -/
嗯,大概接近我正在寻找,但我得到:'错误:值toMap不是Seq.Projection的成员[(Int,Int)]' – aioobe 2010-11-18 11:03:11
这很奇怪。你正在使用哪个版本的Scala? – aioobe 2010-11-18 11:04:51
我正在使用2.8.0.final – 2010-11-18 11:06:39