Skip to content

Instantly share code, notes, and snippets.

@jeremytregunna
Forked from juster/contrived.io
Created April 15, 2012 21:16
Show Gist options
  • Save jeremytregunna/2394862 to your computer and use it in GitHub Desktop.
Save jeremytregunna/2394862 to your computer and use it in GitHub Desktop.
Contrived example of my problem dynamically creating methods
words := list("foo", "bar")
createMethodsFromListInContext := method(lst, ctx,
if(ctx isNil, ctx = call sender)
lst foreach(w,
ctx setSlot(w, method(w println))
)
)
Foo := Object clone
obj := Foo clone
createMethodsFromListInContext(words, obj)
obj foo
obj bar
# Prints:
# foo
# bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment