Scala #008: toArray
|中級篇|
Java.use(better, src=Scala) # ソースコードの歩き方《中級篇》
ソースコードの歩き方《Scala2.8.0》
《著》小粒ちゃん@湘南組、小粒ちゃん@博多組《監修》小泉ひよ子とタマゴ倶楽部
第1版♪2010/07/14
|関連記事|
Scala #008: toArray
》作業中です《
■ リスト項目を選択する
34: val control = new ListView(items.toArray) { --- colorList.scala:34: error: type mismatch; found : Array[?B] required: Seq[?] Note that implicit conversions are not applicable because they are ambiguous: both method wrapLongArray in class LowPriorityImplicits of type (xs: Array[Long])scala.collection.mutable.WrappedArray[Long] and method wrapIntArray in class LowPriorityImplicits of type (xs: Array[Int])scala.collection.mutable.WrappedArray[Int] are possible conversion functions from Array[?B] to Seq[?] val control = new ListView(items.toArray) { ^toArray だけでは、複数の解釈が許され曖昧になるので、エラーになります。そこで、
27: val items = for ((key, value) <- colorNames) yield { key } ... 34: val control = new ListView(items.toArray[String]) {型を指定して、リスト項目を String のインスタンスと見なすことで、この問題を回避します。
》作業中です《