From: "Юрий Соколов" Date: 2013-02-28T06:16:28+09:00 Subject: [ruby-core:53010] Re: [ruby-trunk - Feature #6841] Shorthand for Assigning Return Value of Method to Self --f46d0421a64f6c23cb04d6bb4282 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable =3Dbegin May be: (({obj.foo.bar.baz =3D .to_i })) (({obi.foo[bar.baz] =3D .to_s(16) })) While this not consistent with ||=3D , it looks readable, imho. Or combine both variants: (({obj.foo.bar.baz .=3D .to_i })) (({obi.foo[bar.baz] .=3D .to_s(16) })) ( looks like morse ;) ) 27.02.2013 4:07 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 "wardrop (Tom Wardrop= )" =CE=C1=D0=C9=D3=C1=CC: > > Issue #6841 has been updated by wardrop (Tom Wardrop). > > > =3Dbegin > If there are concerns about using an identifier after ".=3D", then perhap= s a > symbol could be used instead: > > (({obj.foo.bar.baz .=3D :to_i})) > > That would be somewhat consistant with the alternate block syntax (not > sure what it's called): > > (({['a', 'b', 'c'].each &:upcase!})) > =3Dend > ---------------------------------------- > Feature #6841: Shorthand for Assigning Return Value of Method to Self > https://bugs.ruby-lang.org/issues/6841#change-37122 > > Author: wardrop (Tom Wardrop) > Status: Assigned > Priority: Normal > Assignee: matz (Yukihiro Matsumoto) > Category: core > Target version: Next Major > > > =3Dbegin > Quite often in Ruby, I find myself doing something like: > (({my_var[:foo][:bar] =3D my_var[:foo][:bar].to_i})) or (({obj.foo.bar = =3D > 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] .= =3D > to_i})). How this works should be pretty self-explanatory. The (({.=3D})) > 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 thi= s? > =3Dend > > > -- > http://bugs.ruby-lang.org/ > > --f46d0421a64f6c23cb04d6bb4282 Content-Type: text/html; charset=KOI8-R Content-Transfer-Encoding: quoted-printable

=3Dbegin
May be:

(({obj.foo.bar.baz =3D .to_i }))
(({obi.foo[bar.baz] =3D .to_s(16) }))

While this not consistent with ||=3D , it looks readable, im= ho.

Or combine both variants:

(({obj.foo.bar.baz .=3D .to_i }))
(({obi.foo[bar.baz] .=3D .to_s(16) }))

( looks like morse ;) )

27.02.2013 4:07 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5= =CC=D8 "wardrop (Tom Wardrop)" <tom@tomwardrop.com> =CE=C1=D0=C9=D3=C1=CC:

Issue #6841 has been updated by wardrop (Tom Wardrop).


=3Dbegin
If there are concerns about using an identifier after ".=3D", the= n perhaps a symbol could be used instead:

(({obj.foo.bar.baz .=3D :to_i}))

That would be somewhat consistant with the alternate block syntax (not sure= what it's called):

(({['a', 'b', 'c'].each &:upcase!}))
=3Dend
----------------------------------------
Feature #6841: Shorthand for Assigning Return Value of Method to Self
https://bugs.ruby-lang.org/issues/6841#change-37122

Author: wardrop (Tom Wardrop)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: Next Major


=3Dbegin
Quite often in Ruby, I find myself doing something like: (({my_var[:foo][:b= ar] =3D my_var[:foo][:bar].to_i})) or (({obj.foo.bar =3D obj.foo.bar.to_i})= ). Realising this, I thought of what would be a fairly nice shorthand synta= x for this, which could be: (({my_var[:foo][:bar] .=3D to_i})). How this wo= rks should be pretty self-explanatory. The (({.=3D})) operator works exactl= y like any other assignment operator of this nature.

Would be nice to see this in Ruby 2.0. Wondering what others think of this?=
=3Dend


--
http://bugs.ruby-l= ang.org/

--f46d0421a64f6c23cb04d6bb4282--