Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created June 21, 2012 08:24
Show Gist options
  • Save fjolnir/2964572 to your computer and use it in GitHub Desktop.
Save fjolnir/2964572 to your computer and use it in GitHub Desktop.
captureMePlease = "hey I was defined in the root! "
a = { :arg |
block = {:arg |
arg = arg stringByAppendingString:captureMePlease
return arg
}
return block(arg).
}
myBlock = a
numAsStr = a("foo" stringByAppendingString: 321 stringValue.)
numAsStr = numAsStr stringByAppendingString:" Three Two One"
print(numAsStr)
class Foo
+ classMethod {
print("I'm a class method %@", captureMePlease)
}
- instanceMethod: iMethArg {
print("From: %@ To: %@", iMethArg, self)
}
end
return myBlock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment