Skip to content

Instantly share code, notes, and snippets.

@danielpetisme
Created August 27, 2013 08:49
Show Gist options
  • Save danielpetisme/6351222 to your computer and use it in GitHub Desktop.
Save danielpetisme/6351222 to your computer and use it in GitHub Desktop.
Discover arguments size at runtime
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