From: shevegen@... Date: 2020-05-09T04:23:17+00:00 Subject: [ruby-core:98223] [Ruby master Feature#15921] R-assign (rightward-assignment) operator Issue #15921 has been updated by shevegen (Robert A. Heiler). I do not have any particularly strong opinion either way, but I would like to point out that the example given by duerst made the most sense to me personally, from all the examples given above as to the potential usefulness. :) I would actually go as far and suggest to include that example, or a similar one, for the rightward-assignment in the official documentation (the content in this issue will otherwise be forgotten eventually, and when people may stumble upon that feature, they may ask "What is this feature used for?"). To be clear, I refer to this specific example by Martin there: $stdin.read .scan(/[-\w']+/) .group_by(&:downcase) .collect { |key, value| Word.new(key, value.count) } .sort_by { |w| [-w.text.length, w.text] } => words where the order of the code pieces aligns with the order of what's happening, and **there's no need to go back with your eyes** . In particular the last explanation made sense to me, and I write this in the sense that I will most likely not use that specific feature (I don't think I need it). I think duerst's explanation was really good - perhaps there are more use cases, but the explanation given there made by far the most sense to me personally. ---------------------------------------- Feature #15921: R-assign (rightward-assignment) operator https://bugs.ruby-lang.org/issues/15921#change-85463 * Author: nobu (Nobuyoshi Nakada) * Status: Closed * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- From https://bugs.ruby-lang.org/issues/15799#change-78465, proposal of the rightward-assignment operator by `=>`. ``` $ ./ruby -v -e '(1..).lazy.map {|x| x*2} => x' -e 'p x.first(10)' ruby 2.7.0dev (2019-06-12T06:32:32Z feature/rassgn-assoc c928f06b79) [x86_64-darwin18] last_commit=Rightward-assign by ASSOC [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] ``` https://github.com/nobu/ruby/tree/feature/rassgn-assoc -- https://bugs.ruby-lang.org/ Unsubscribe: