> So param=[] means param=Array.new, and it gets called every single time you call the method with a parameter missing.
How far down does Ruby copy? (A default value could be deep.) How does the programer specify a different level (including no copying)?
Python's rule seems bad until you try to use the alternatives outside the single case that they were designed for. Python's rule handles all cases reasonably.
It doesn't copy anything - it literally is calling "Array.new()" to generate a new array, every time one is needed.
To do it the python way, you'd have to use a global variable to store the array - which is exactly what python is doing for you. Doesn't sound so handy when its put like that, huh?
How far down does Ruby copy? (A default value could be deep.) How does the programer specify a different level (including no copying)?
Python's rule seems bad until you try to use the alternatives outside the single case that they were designed for. Python's rule handles all cases reasonably.