Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

mutable vs immutable

Mutable instance is passed by reference.

Immutable instance is passed by value.

Abstract example. Lets suppose that there exists a file named txtfile on my HDD. Now, when you are asking me to give you the txtfile file, I can do it in the following two modes:

I can create a shortcut to the txtfile and pass shortcut to you, or
I can do a full copy of the txtfile file and pass copied file to you.
In the first mode, the returned file represents a mutable file, because any change into the shortcut file will be reflected into the original one as well, and vice versa.

In the second mode, the returned file represents an immutable file, because any change into the copied file will not be reflected into the original one, and vice versa.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mutable #immutable
ADD COMMENT
Topic
Name
9+2 =