Value Types in the Real World π
Suppose youβre reading something fantastic, and you want a friend to read it too. π
What do you need to give your friend so that he can read it tooβ
To give your friend a copy, youβd need to photocopy all the pages and then give it to him, At that point, he has his own complete copy of the document. π
In this situation, youβre dealing with value type behaviorβοΈ
All the information is directly in your hands, you donβt need to go anywhere else to get it.
Your copy of the information is also independent of your friendβs after youβve made the copy. π₯
You could add some notes to your pages, and his pages wouldnβt be changed at all.π π»ββοΈ
γ°γ°γ°γ°γ°γ°
#Types #ValueTypes
@ProgrammingTip
Suppose youβre reading something fantastic, and you want a friend to read it too. π
What do you need to give your friend so that he can read it tooβ
To give your friend a copy, youβd need to photocopy all the pages and then give it to him, At that point, he has his own complete copy of the document. π
In this situation, youβre dealing with value type behaviorβοΈ
All the information is directly in your hands, you donβt need to go anywhere else to get it.
Your copy of the information is also independent of your friendβs after youβve made the copy. π₯
You could add some notes to your pages, and his pages wouldnβt be changed at all.π π»ββοΈ
γ°γ°γ°γ°γ°γ°
#Types #ValueTypes
@ProgrammingTip
Reference Types in the Real World π
Compare that with the situation where youβre reading a web page. π
This time, all you have to give your friend is the URL of the web page. βοΈ
This is reference type behavior, with the URL taking the place of the reference. βοΈ
In order to read the document, you have to navigate the reference by putting the URL in your browser and asking it to load the page. βπ»
If the web page changes for some reason, both you and your friend will see that change the next time each of you loads the page. ππ»
γ°γ°γ°γ°γ°γ°
#Types #ReferenceTypes
@ProgrammingTip
Compare that with the situation where youβre reading a web page. π
This time, all you have to give your friend is the URL of the web page. βοΈ
This is reference type behavior, with the URL taking the place of the reference. βοΈ
In order to read the document, you have to navigate the reference by putting the URL in your browser and asking it to load the page. βπ»
If the web page changes for some reason, both you and your friend will see that change the next time each of you loads the page. ππ»
γ°γ°γ°γ°γ°γ°
#Types #ReferenceTypes
@ProgrammingTip