pass by reference pass by value

well I think there is some mix up here, object references are values, that is the variables are like normal primitive types so when u pass the reference in a function the reference is passed by value, but remember its pointing to an object. so if you assign the pointer(reference variable) that was passed by value to another object it simple cuts the link to the original object that it pointed to. So when u leave that function and get to the parent scope the old pointer is still pointing to the original object and when u display it, it gives the original but if you use the pointer and call the pointed objects method, it will modify it, so I believe python like java the objects are still passed by reference and the reference are actually passed by value. dont get it mixed up, correct me if I am wrong

Reply

The content of this field is kept private and will not be shown publicly.
Type this to prove you are human.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Ads (you can disable these if you log in)