H
Harry Kakueki
Maybe I'm missing something obvious here, but...
Does this result surprise anyone else or just me?
I was expecting a_hash and an_arr to be local to the method.
Did I just do something stupid?
def scope_q(a_hash,an_arr,a_num)
a_hash["b"] = 3
an_arr[1] = 5
a_num += 1
end
h = {"a"=>1,"b"=>2,"c"=>3,"d"=>4}
a = [1,2,3,4]
n = 7
scope_q(h,a,n)
p h #> {"a"=>1, "b"=>3, "c"=>3, "d"=>4}
p a #> [1, 5, 3, 4]
p n #> 7
#ruby 1.9.1p243
Harry
Does this result surprise anyone else or just me?
I was expecting a_hash and an_arr to be local to the method.
Did I just do something stupid?
def scope_q(a_hash,an_arr,a_num)
a_hash["b"] = 3
an_arr[1] = 5
a_num += 1
end
h = {"a"=>1,"b"=>2,"c"=>3,"d"=>4}
a = [1,2,3,4]
n = 7
scope_q(h,a,n)
p h #> {"a"=>1, "b"=>3, "c"=>3, "d"=>4}
p a #> [1, 5, 3, 4]
p n #> 7
#ruby 1.9.1p243
Harry