dotty seq mapping to union

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


dotty seq mapping to union



I cant get the following code to compile with the latest dotty (0.9.0-RC1), and at first glance it looks like it should...


object UnionMapping {

private def parse(string: String): Int | Double = {
if(string.contains("."))
string.toDouble
else
string.toInt
}

def test_number = {
val strings: Seq[String] = Seq("123, 2.0, 42")
// Works
val asdf: Seq[AnyVal] = strings.map(parse(_))
// Fails to compile
val union: Seq[Int | Double] = strings.map(parse(_))
}

}



does anyone have any insight into why its failing and whether its expected to work?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

Better method to check all objects' parameters with a single call