From: Ehsanul Hoque Date: 2009-11-17T18:39:12+09:00 Subject: Re: Meaning of '!(...' EG: "myObject.parse!(argv)" ..? --_d6698622-4174-4e85-b099-382b8a5d5401_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable >=20 > Sorry Ryan... I'm still not getting it :-( >=20 > What is that exclamation mark doing? Could I substitute lets say a 'w'=20 > for the exclamation mark? >=20 > opts.send(:parse!=2C argv) =3D> opts.send(:parsew=2C argv) > opts.send(:parse=2C argv) =3D> opts.send(:parse=2C argv) >=20 > If I can=2C then I understand it. There are in fact two different methods= =20 > 'parsew' and 'parse'. But if thats true... then in my orginal code=20 > above=2C there wasn't a 'parse!' method defined. >=20 > --=20 > Posted via http://www.ruby-forum.com/. >=20 I think you've got it. Basically parse!=2C and I mean all of it including t= he exclamation mark=2C is a method defined separately from parse. In your o= ptions class=2C they might look like this: class Options def parse!(argv) # parsing code end def parse(argv) opts =3D self.dup opts.parse!(argv) end end The example implementation is just a common idiom in ruby where a method en= ding in a "bang"=2C or exclamation point is a destructive method=2C alterin= g the state of the object=2C whereas the non-bang version of the method act= s on a duplicate object=2C so as to keep the actual object unaltered. There= is nothing special about the bang in how it is processed in ruby=2C it's j= ust taken as part of the method name. So yes=2C you can just replace it wit= h "w" or something. The reason for the bang is just ruby convention. If you= wanted=2C you could reverse the definitions=2C and it would work fine=2C b= ut just be confusing (don't do that=2C go by convention).=20 Hope that's clear. - Ehsan =20 _________________________________________________________________ Windows 7: It works the way you want. Learn more. http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=3DPID24727::T:= WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen:112009v2= --_d6698622-4174-4e85-b099-382b8a5d5401_--