Ruby is "pass by reference". The difference is as follows: If you pass by reference, you can do bad things to the original object:
x = [ "virgin" ]
def do_bad_things_to( arg )
arg.clear << "bad things"
end
do_bad_things_to( x )
If you pass by value, you get the value of the original object and can work with it, but you cannot do bad things to the original object. You consume more memory, as the copy of the the original object's value also takes memory:
def pass_by_value( arg )
arg.dup
end
y = [ "virgin" ]
do_bad_things_to( pass_by_value( y ) )
p x #=> [ "bad things" ]
p y #=> [ "virgin" ]
To immutable objects (numbers, symbols, true, false, nil...), one cannot do bad things by the virtue of their immutability. It is oft said, that in Ruby, they are passed by value, but in fact, the distinction makes little sense for them, just as it makes little sense to keep many copies of their internals in the memory.
UPDATE: There seems to be terminological contention as to what 'reference' means. In Ruby, Jörg Mittag's "pass by reference" is explicitly achieved by closures that close over local variables:
baz = "Jörg"
define_method :pass_by_Jorgs_reference_to_baz do baz = "Boris" end
pass_by_Jorgs_reference_to_baz
baz #=> "Boris"