Saturday, 24 August 2013

Can we say that using "pass by reference" is always better than "pass by value"?

Can we say that using "pass by reference" is always better than "pass by
value"?

In C# or php or other languages, there are 2 ways to pass a value to a
function, pass it by value and pass it by referece.
Pass parameter by value make the value copied in the function, so this
need a extra memory space although the memory space will be reclaimed
after running outside the function.
But passing parameter by reference no need to copy a value, it's save the
memory. From this perspective, can we say that using "pass by reference"
is always better than "pass by value"?

No comments:

Post a Comment