fork download
  1. import std.stdio;
  2.  
  3. class Foo
  4. {
  5. void opDispatch(string name, T...)(T args)
  6. {
  7. writeln("Called method: ", name);
  8. foreach (i, arg; args) writefln("args[%d] == %s", i, arg);
  9. }
  10. }
  11.  
  12. void main()
  13. {
  14. Foo bar = new Foo();
  15. bar.baz();
  16. bar.foo("hello", [5,10,15], 3.14f, ["foo":5, "bar":10], true);
  17. }
Success #stdin #stdout 0.01s 2148KB
stdin
Standard input is empty
stdout
Called method: baz
Called method: foo
args[0] == hello
args[1] == 5 10 15
args[2] == 3.14
args[3] == [bar:10,foo:5]
args[4] == true