08/02/08 22:15:07
>>711
自分で注意深くコードを書いて試すといい
ちなみにいわゆる参照渡しだ
class Test
def initialize(str,h)
@str = str; @h = h
end
def modify
@str.replace('MODIFIED')
@h['MODIFIED'] = 'MODIFIED'
end
end
str = 'default'
h = {'key'=>'value'}
Test.new(str,h).modify
p str
p h
# ================================
$ ruby ./test.rb
"MODIFIED"
{"MODIFIED"=>"MODIFIED", "key"=>"value"}