Created
October 5, 2016 23:43
-
-
Save willkurt/d031a2f4b53978e19d9d5bd04efda832 to your computer and use it in GitHub Desktop.
Why referential transparency matters...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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