Hacker News new | past | comments | ask | show | jobs | submit login

That's standard behavior for object oriented languages. A different example with functions:

  function add(x, y) {
    return x + y
  } 
  a = 5
  add(a, 1)
  print(a)
A language printing 6 is pass by reference. A language printing 5 is pass by value. Both would print 6 for this code

  a = add(a, 1)
  print(a)
However a language like Erlang would end with an error when trying to reassign a new value to a.



I correct myself. The function in the first example should be

  function add(x, y) {
    x = x + y
    return x
  }




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: