From: daniel@...42.com Date: 2020-04-17T14:13:14+00:00 Subject: [ruby-core:97943] [Ruby master Feature#16794] Rightward operators Issue #16794 has been updated by Dan0042 (Daniel DeLorme). Actually instead of using `|>` as the common element between rightward operators, maybe just the pipe character would be enough. `|:` (because `|=` is taken) `|~` `|>` `|>>` `|**` ---------------------------------------- Feature #16794: Rightward operators https://bugs.ruby-lang.org/issues/16794#change-85165 * Author: Dan0042 (Daniel DeLorme) * Status: Open * Priority: Normal ---------------------------------------- While reading #15921 (r-assign) and #16670 (reverse pattern matching order) I felt a certain commonality to these and #15799 (pipeline) and I thought maybe there's currently a narrow window of opportunity to adopt an overarching and harmonious syntax for all of these "rightward" operations, rather than ad-hoc syntax for each. I am **not** suggesting that all of the operators below should be adopted, or implemented at once, or exactly as-is; rather the idea is that the proposals linked above surrounding righward-ness could share elements in order to make them easy to distinguish from previous/existing syntax. So here go the (wild) ideas: `=|>` rightward assignment: `expr =|> var` is equivalent to `var = expr`, also allow `rescue =|> err` for consistency. `~|>` rightward destructuring assignment / pattern match: `expr ~|> pattern` is equivalent to `expr in pattern`, just more natural when doing assignment without a pattern match (i.e. no possibiilty of NoMatchingPatternError). And maybe could be allowed as expression/condition? `|>` pipe to first argument of right-side method: `expr |> foo(1)` is equivalent to `foo(expr,1)` `|>>` pipe to last argument of right-side method: `expr |>> foo(1)` is equivalent to `foo(1,expr)` `**|>` pipe hash to keyword arguments of right-side method: `expr **|> foo(1)` is equivalent to `foo(1,**expr)`, ok, I know, crazy idea :-) -- https://bugs.ruby-lang.org/ Unsubscribe: