0

I have a variable (say a list) and I want to pass it to different functions (which gives different values for the variable) without the original value being changed i.e when one function modifies the variable value, the second function should receive the original value in the variable not the modified one.

I face a problem that the second function I call uses the value modified by the first function (and not the original vale).

Ramil
  • 1
  • 1
  • 1
    Make a copy of the passed variable in each function and return that then. http://paste.ubuntu.com/21139418/ This way you're not changing the original variable. I was writing an answer but the question got closed, so I had to upload the code to a pastebin sort of site. Hope that helps. – Harrison Jul 27 '16 at 13:36
  • Thanks @hleggs ! It helped. I am a beginner here. I would like to ask one more thing. Is this what is called call by reference? – Ramil Jul 28 '16 at 13:20
  • Yes, this is passing by reference. – Harrison Jul 28 '16 at 16:44
  • Thank you @hleggs! – Ramil Jul 28 '16 at 17:07

0 Answers0