3 ms·
Yeah I kind of wish there was a way to still use `?` inside map/filter/etc. lambdas. Error handling with that functional style is generally way more awkward tha
by IshKebab 2y ago
Yeah I kind of wish there was a way to still use `?` inside map/filter/etc. lambdas. Error handling with that functional style is generally way more awkward than for loops, but also it's often more elegant in other ways (e.g. Rayon).
I think Ruby has some kind of feature that works like that but IIRC it looked less foot-gun more foot-bazooka. Does anyone know of any languages that solve that problem elegantly?
- zozbot234 2y ago"Ad-Hoc Effects in Rust" https://capi.hannobraun.com/daily/2024-12-12 https://capi.hannobraun.com/daily/2024-12-12 discusses the issue in detail. An early attempt at a solution (2022) was provided by https://blog.rust-lang.org/inside-rust/2022/07/27/keyword-generics.html https://blog.rust-lang.org/inside-rust/2022/07/27/keyword-ge...
- mijoharas 2y agoWhat's the ruby feature you're referring to?
- IshKebab 2y agohttps://medium.com/swlh/returning-from-a-ruby-proc-beware-of-where-you-land-a29add7ddd9d https://medium.com/swlh/returning-from-a-ruby-proc-beware-of...
- anon-3988 2y agoI think what you want is a short-circuiting behavior. I don't see a problem with the status quo, if map is able to short-circuit, that means that it runs in order and have side effects. If your "map" can cause the whole function to return, then just write a for-loop. I don't even know if it should return from the whole function or just stop the mapping?