मान लीजिए मैं कोड निम्नलिखित है:स्काला का या तो अधिकार के रूप में टपल साथ
val either: Either[String, (Int, Int)] = Right((1,2))
for {
(a, b) <- either.right
} yield a + b
जब मैंने इसे आरईपीएल में मूल्यांकन मैं
:13: error: constructor cannot be instantiated to expected type; found : (T1, T2) required: scala.util.Either[Nothing,(Double, Double)] (a, b) <- a.right ^:14: error: not found: value a } yield a + b ^
मैं ऐसे त्रुटि क्यों हैं मिल सकता है? क्या मैं किसी भी अधिकार से टुपल पर पैटर्न मिलान नहीं कर सकता?
मैं स्कैला 2.10.3 का उपयोग कर रहा हूं। इसके अलावा इस तरह का एक अजीब प्रकार क्यों है: 'scala.util के साथ उत्पाद के साथ Serializable। या तो [स्ट्रिंग, Int] '? क्यों न सिर्फ 'scala.util.Either [स्ट्रिंग, Int] ' – maks