From: Judson Lester Date: 2009-10-31T09:25:00+09:00 Subject: Re: In-place parameter modification --00504502cd68ee243b047730185f Content-Type: text/plain; charset=UTF-8 Actually, chomp!(string) doesn't modify string, it modifies $_ (which, if I recall correctly, is set by the -n and -p switches to ruby). String#chomp! modifies the recipient. Finally: ruby is a pass-by-reference language, so if you actually do make changes the parameters of a method, the callers variables will change as well. For instance: def make_bacon(string) string.replace "Chunky bacon." end hi = "hello" make_bacon(hi) hi #=> "Chunky bacon." Judson On Fri, Oct 30, 2009 at 4:38 PM, Dave Anderson wrote: > Native to ruby are several methods that change passed-in parameters > in-place, such as chomp!(somestring). But I don't see any info on > creating these things myself. Is it possible to write methods that > change parameters this way? > -- > Posted via http://www.ruby-forum.com/. > > --00504502cd68ee243b047730185f--