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!
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!
Hello Justin!
No, this will not send a copy of v to some_method, but v itself.
Cheers,
Arthur
Great, thanks so much!
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”
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs