You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like the pipe operator, but works on elements of collections. Accepts local free functions, proc objects and blocks. Also accepts methods of the items.
fn(value) -> value + 1
puts [1,2,3] |>> fn |>> fn -- outputs [3,4,5]
puts [1,2,3] |>> .to_s -- calls a method on each object, outputs ["1", "2", "3"]
Essentially sugar for map. But nice sugar.
We could also have ?> for select, !> for reject, and so on.
The text was updated successfully, but these errors were encountered:
These are very specific sugars for very specific narrow-use methods.
I went down the road of zillions of operators in Jytron, about two-three years ago, and finally concluded that they sometimes took more screen estate, while still making code less clear. Haskell fails in this regard to, as far as I am concerned.
It does give important food for thought in any event! Some ideas about more general construct for accomplishing above in a terse way starts bubbling in my head. I'll get back to this.
Like the pipe operator, but works on elements of collections. Accepts local free functions, proc objects and blocks. Also accepts methods of the items.
Essentially sugar for
map
. But nice sugar.We could also have
?>
forselect
,!>
forreject
, and so on.The text was updated successfully, but these errors were encountered: