2 ms·
Oof... looks more object-oriented hell to me. I really like the way functional programming languages separate types from functions, and I've been adopting this
by rogerkeays 3y ago
Oof... looks more object-oriented hell to me. I really like the way functional programming languages separate types from functions, and I've been adopting this pattern in my Java code. Extension methods let you do this and keep your fluent api. Thanks for the link though, I didn't know about implicit classes.
- twic 3y agoWe did Scala at an old job and various kinds of implicits got us into so much trouble. I think if you use them judiciously, they'll be fine, but you need quite a bit of experience and maturity to use them judiciously, which most of us lacked.
- valenterry 3y agoThe usage for extension methods is very easy and safe, there is IDE support too. It's really not a problematic usecase for implicits. But yeah, implicits are powerful and should be used carefully.
- vips7L 3y agoScala 3 has actual extension methods. extension (c: Circle) def circumference: Double = c.radius * math.Pi * 2 val c = Circle(2, 3, 5) c.circumference()