Immutable vs mutable object

Pass by Value The function receives a copy of the argument’s value. Modifications to the parameter inside the function do not affect the original argument. Pass by Reference The function receives a reference (or address) to the actual argument. Modifications to the parameter inside the function affect the original argument because both the argument and the parameter refer to the same memory location. Mutable Objects (like lists or dictionaries): The function can modify the object in place, and those changes will be reflected outside the function. ...

October 22, 2024 · 2 min · Lin Lin Hlaing