Re:"Useless syntax sugar": Numbered block parameters in Ruby
by inopinatus on Thursday October 12, 2023 @12:15AM
(#37853426)
my instinct is
["a","bb","ccc","dddd"].grep /.../
but then, I'm a recovering perl hacker
Re:"Useless syntax sugar": Numbered block parameters in Ruby
by jonahx on Thursday October 12, 2023 @01:25AM
(#37853718)
Love it!
Re:"Useless syntax sugar": Numbered block parameters in Ruby
by dragonwriter on Thursday October 12, 2023 @03:53AM
(#37854556)
Yeah, mirroring the Haskell code, while possible in Ruby, is definitely not the best Ruby-aware approach, either for concision or clarity. The composability is available, but the problems where it is the best solution are different.
> ["a","bb","ccc","dddd"].filter &(2.method(:<) << :length.to_proc)
I can't imagine a stronger case for GP's thesis. The point-free ruby rewrite is so baroque and needlessly circuitous... the extra variable is a far lesser evil, and more concise: