Created
July 17, 2010 06:37
-
-
Save ELLIOTTCABLE/479309 to your computer and use it in GitHub Desktop.
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
Inimino’s way: | |
foo = routine { | |
if argument == 1, return ‘a’ | |
if argument == 2, return ‘b’ | |
if argument == 3, return ‘c’ | |
} | |
“now I want to change the result of looking up 2, such that it returns ‘CHANGED’. I have to write an entirely new | |
routine, with exactly the same contents for all the other elements, but a new return value for 2:” | |
foo = routine { | |
if argument == 1, return ‘a’ | |
if argument == 2, return ‘CHANGED’ | |
if argument == 3, return ‘c’ | |
} | |
My way: | |
foo = ( | |
1: a | |
2: b | |
3: c | |
) | |
“now I want to change the result of looking up 2, such that it returns ‘CHANGED’. I only have to change the | |
*data* stored for `2`” | |
foo set(2, ‘CHANGED’) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment