Skip to content

Instantly share code, notes, and snippets.

@willkurt
Created October 5, 2016 23:43
Show Gist options
  • Save willkurt/d031a2f4b53978e19d9d5bd04efda832 to your computer and use it in GitHub Desktop.
Save willkurt/d031a2f4b53978e19d9d5bd04efda832 to your computer and use it in GitHub Desktop.
Why referential transparency matters...
//this is valid Ruby, Python and JavaScript
myList = [1,2,3]
myList.reverse()
newList = myList.reverse()
//Q. What is the value of newList in each of those three languages??
//answers below!!!
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
//Answers
Ruby: newList == [3,2,1]
Python: newList == None
JavaScript: newList == [1,2,3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment