pass by reference or pass by value

Write at 2016 Dec 09 in notes Ruby

When we are in school, they said it’s either passing by reference or pass by value. When pass reference, you can change the value. When pass by value you cannot change anything.

Let’s take this in Ruby

hash = {foo: 12, bar: 3}

def c1(h)
  c1[:foo] = 100
end

Run them in IRB, yield below result: