Neden bu yapı Scala'da bir Tür Uyuşmazlığı hatasına neden oluyor? Ben List ile Bazı geçersenizAnlamak İçin Scala'da Uyuşmazlık Türleri
for (first <- Some(1); second <- List(1,2,3)) yield (first,second)
<console>:6: error: type mismatch;
found : List[(Int, Int)]
required: Option[?]
for (first <- Some(1); second <- List(1,2,3)) yield (first,second)
ince derler:
for (first <- List(1,2,3); second <- Some(1)) yield (first,second)
res41: List[(Int, Int)] = List((1,1), (2,1), (3,1))
Bu aynı zamanda çalışıyor: comprehensions için
for (first <- Some(1); second <- Some(2)) yield (first,second)
Scala'nın başarısız örnekte geri dönmesini ne bekliyorsunuz? –
Yazarken, bir Option [Liste [(Int, Int)]] alacağımı düşündüm. –