[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Avoiding copies of method arguments

Justin To

6/17/2008 3:31:00 PM

Hello!

v = 'abc'

some-method(v)

This will send a copy of v to the method, right? If so, how does one
avoid this. How can one send the original and avoid the extra
consumption of resources from copying? Thanks!
--
Posted via http://www.ruby-....

4 Answers

schreiber.arthur@googlemail.com

6/17/2008 3:44:00 PM

0

Hello Justin!

No, this will not send a copy of v to some_method, but v itself.

Cheers,
Arthur

On 17 Jun., 17:31, Justin To <te...@hotmail.com> wrote:
> Hello!
>
> v = 'abc'
>
> some-method(v)
>
> This will send a copy of v to the method, right? If so, how does one
> avoid this. How can one send the original and avoid the extra
> consumption of resources from copying? Thanks!
> --
> Posted viahttp://www.ruby-....

Justin To

6/17/2008 3:48:00 PM

0

Great, thanks so much!
--
Posted via http://www.ruby-....

J. Cooper

6/17/2008 3:50:00 PM

0

Just test it out:

irb >> def change(str)
irb >> str << 'z'
irb >> end
irb => nil
irb >> v
irb => "abc"
irb >> change(v)
irb => "abcz"
irb >> v
irb => "abcz"

--
Posted via http://www.ruby-....

Fattuchus

3/20/2011 9:00:00 PM

0

On Mar 20, 9:02 am, Susan S <otoeremovet...@ix.netcom.com> wrote:
> In soc.culture.jewish.moderated  I read this message from mm
> <NOPSAMmm2...@bigfoot.com>:
>
>
>
> >I can't get the Helen Thomas link to work.  Is she naked?
>
> In a sense; her miserable anti-Semitism is exposed with all its ugly,
> stupid, dishonesty.
> [snip]
>
> Susan Silberstein

Great response. BTW, I like the comments made by others at the link.