Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Noobie question: saving the values
Druhie Almighty
9/29/2007 11:28:00 AM
May you forgive me for this irrelevant thread but nonetheless, I need
your help.
I'm new at programming and recently I've faced with the problem
connected with the peculiarity of Ruby. Unlike many other languages, the
variables in it contain not the objects themselves but only links to
them, right?
So can you please explain me why do these two operations very close to
each other result in different ways, considering the fact that both a
and b contain the same link?
1)
a="13"
b=a
a="12"
puts b --> 13
2)
a="13"
b=a
a[1]="2"
puts b --> 12
To be more exact, in my program I need an array and a
variable=method(array). But when I call the method, the array itself
changes as well. How do I save the value of the array and get the
neccesary value of the variable at the same time?
P.S. And yes, I sought for solution in a guide but so far haven't found
anything.
--
Posted via
http://www.ruby-...
.
2 Answers
David A. Black
9/29/2007 11:35:00 AM
0
Druhie Almighty
9/29/2007 12:13:00 PM
0
Thanks for your quick help, looks like I'm starting to understand
something and the program to be done by tomorrow works properly at last
:)
I hope you don't mind if I come again with a couple of another newbie's
questions? :)
Thanks a lot once again.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Noobie question: saving the values
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