Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created July 17, 2010 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ELLIOTTCABLE/479309 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/479309 to your computer and use it in GitHub Desktop.
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