From: Alex van der Ruchei Date: 2013-01-13T05:24:17+09:00 Subject: Re: uniq vs uniq! --50f1c668_3a95f874_692 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Awesome explanation=21 On Sunday, 13 January 2013 =D0=B3. at 3:14, Dave Aronson wrote: > On Sat, Jan 12, 2013 at 3:03 PM, rubyinfo wrote: > =20 > > 1.8.7 :001 > =5B=5D.uniq=21 > > =3D> nil > > 1.8.7 :002 > =5B=5D.uniq > > =3D> =5B=5D > > =20 > > 1.9.3p194 :001 > =5B=5D.uniq > > =3D> =5B=5D > > 1.9.3p194 :002 > =5B=5D.uniq=21 > > =3D> nil > > =20 > > =20 > > Why =3F > =20 > Why what=3F > =20 > Why are the results reversed=3F They're not, you typed them in one > order the first time and the other the second. > =20 > Why does the bang version return nil=3F As the docs > (http://www.ruby-doc.org/core-1.9.3/Array.html=23method-i-uniq-21) say,= > =22Returns nil if no changes are made (that is, no duplicates are > found).=22 Of course in =5B=5D there will be no dups. > =20 > Why IS there a difference=3F Generally, when there are both bang and > normal versions of a method, the bang version affects the object > passed in, while the normal version acts on (and returns) a duplicate. > In the bang case, you usually don't care about the return value, and > are using it instead for the effect on the receiver. > =20 > Why do fools fall in love=3F Why do birds sing=3F Why is this night > different from all other nights=3F Why ask why, drink Bud Dry=21 ;-) > =20 > -Dave > =20 > -- =20 > Dave Aronson, the T. Rex of Codosaurus LLC, > secret-cleared freelance software developer > taking contracts in or near NoVa or remote. > See information at http://www.Codosaur.us/. > =20 > =20 > =20 --50f1c668_3a95f874_692 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Awesome explanation=21
=20 =20

On Sunday, 13 January = 2013 =D0=B3. at 3:14, Dave Aronson wrote:

On Sat, Jan 12, 2013 at 3:03 PM,= rubyinfo <rubyinfo=40a= ptifuge.com> wrote:

1.8.7 :001 > =5B=5D.uniq=21
=3D> nil
=
1.8.7 :002 > =5B=5D.uniq
=3D> =5B=5D

=
1.9.3p194 :001 > =5B=5D.uniq
=3D> =5B=5D
1.9.3p194 :002 > =5B=5D.uniq=21
=3D> nil


Why =3F

<= /div>
Why what=3F

Why are the results revers= ed=3F They're not, you typed them in one
order the first time = and the other the second.

Why does the bang vers= ion return nil=3F As the docs
=22Returns = nil if no changes are made (that is, no duplicates are
found).=22= Of course in =5B=5D there will be no dups.

Why= IS there a difference=3F Generally, when there are both bang and
<= div>normal versions of a method, the bang version affects the object
passed in, while the normal version acts on (and returns) a duplica= te.
In the bang case, you usually don't care about the return = value, and
are using it instead for the effect on the receiver.=

Why do fools fall in love=3F Why do birds sing= =3F Why is this night
different from all other nights=3F Why = ask why, drink Bud Dry=21 ;-)

-Dave
<= br>
--
Dave Aronson, the T. Rex of Codosaurus LLC,
secret-cleared freelance software developer
taking con= tracts in or near NoVa or remote.
See information at http://www.Codosaur.us/.
=20 =20 =20 =20

--50f1c668_3a95f874_692--