Posts

Showing posts with the label dotty

dotty seq mapping to union

Image
Clash 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.