Created
November 2, 2011 16:16
-
-
Save draegtun/1334070 to your computer and use it in GitHub Desktop.
block() with unknown arity
This file contains hidden or 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
arity := block ( | |
"You provided #{call argCount} args" interpolate println | |
call evalArgs foreach (arg, "... #{arg}" interpolate println) | |
) | |
// "call evalArgs" is a shortcut for "call message argsEvaluatedIn(call sender)" | |
var := "test" | |
arity call( "1", 2 + 2, var ); | |
arity call | |
# You provided 3 args | |
# ... 1 | |
# ... 4 | |
# ... test | |
# You provided 0 args |
This file contains hidden or 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
arityUnEval := block ( | |
"You provided #{call argCount} args" interpolate println | |
call message arguments foreach (arg, "... #{arg}" interpolate println) | |
) | |
arityUnEval call( "1", 2 + 2, var ); | |
# You provided 3 args | |
# ... "1" | |
# ... 2 +(2) | |
# ... var |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment