Created
August 27, 2013 08:49
-
-
Save danielpetisme/6351222 to your computer and use it in GitHub Desktop.
Discover arguments size at runtime
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
module varargs | |
local function tests = { | |
let map = java.util.HashMap() | |
map: put("test0", { println("empty")}) | |
map: put("test1", |a| -> println(a)) | |
map: put("test2", |a, b| -> println(a + " " + b)) | |
map: put("test3", |a, b, c| -> println(a + " " + b + " " + c)) | |
return map | |
} | |
function main = |args| { | |
let dynob = DynamicObject() | |
foreach (entry in tests(): entrySet()) { | |
dynob: define(entry: getKey(), |this, args...| -> entry: getValue(): invokeWithArguments(args: asList())) | |
} | |
dynob: test0() | |
dynob: test1("a") | |
dynob: test2("a", "b") | |
dynob: test3("a", "b", "c") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment