Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Assignment as a reference?
dougal.s
8/20/2007 4:28:00 PM
On 20 Aug 2007, at 17:20, Morgan Grubb wrote:
> foo = 'bar' #=> bar
> foo2 = foo #=> bar
> foo.gsub! 'bar', 'wibble' #=> wibble
> foo2 #=> wibble
What you have experienced is reference assignment. If you wish to
duplicate only the content, and not the reference, then you should to
use .dup.
> foo = "bar"
=> "bar"
> foo2 = foo.dup
=> "bar"
> foo = "wibble"
=> "wibble"
> foo2
=> "bar"
Hope this helps you out.
Douglas F Shearer
dougal.s@gmail.com
http://douglasfs...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Assignment as a reference?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password