From: "wardrop (Tom Wardrop)" Date: 2013-04-03T15:55:30+09:00 Subject: [ruby-core:53947] [ruby-trunk - Feature #6841] Shorthand for Assigning Return Value of Method to Self Issue #6841 has been updated by wardrop (Tom Wardrop). =begin (({Regarding obj.foo.bar.baz = .to_i})) syntax, with the dot prefix on the ((|to_i|)), another proposal has been made further down the discussion for issue #8191. The idea is that an expression beginning with a dot could be an inferred method call on the result of the last expression. Just consider that before using the dot prefix syntax for anything else. =end ---------------------------------------- Feature #6841: Shorthand for Assigning Return Value of Method to Self https://bugs.ruby-lang.org/issues/6841#change-38156 Author: wardrop (Tom Wardrop) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: Next Major =begin Quite often in Ruby, I find myself doing something like: (({my_var[:foo][:bar] = my_var[:foo][:bar].to_i})) or (({obj.foo.bar = obj.foo.bar.to_i})). Realising this, I thought of what would be a fairly nice shorthand syntax for this, which could be: (({my_var[:foo][:bar] .= to_i})). How this works should be pretty self-explanatory. The (({.=})) operator works exactly like any other assignment operator of this nature. Would be nice to see this in Ruby 2.0. Wondering what others think of this? =end -- http://bugs.ruby-lang.org/