3 ms·
the only problem/wierdness might happen with -> is if switch will return a lambda. i.e. case "Foo" -> () -> "newfoo" looks silly at first. well scala supports t
by merb 9y ago
the only problem/wierdness might happen with -> is if switch will return a lambda. i.e. case "Foo" -> () -> "newfoo"
looks silly at first. well scala supports that and it looks strange at first but in functional programming, these patterns aren't as strange as they first look.
- nikolay 9y agoPeople already use return if the switch is the last statement in a function, so, all this "sugar" is only confusing, inconsistent, and not improving the readability or the learning curve.
- merb 9y agowell I think the sugar is fine. just the none sugar is kinda.. wierd. who would ever write: 'case "foo": break 1' it's just unnecessary. (but they probably do it for backwards compat or so, no idea..)