#1503 Named function arguments

ivix Sat 23 Apr 2011

Hello there.

I am new in Fantom.

I just want know is Fantom support named arguments for functions like Python?

Or maybe it is realized in different way?

I think Python named arguments is very useful ability.

go4 Sat 23 Apr 2011

Ruby's way:

def image(opt={})   
  default_opt = {:height => 25, :width => 10}   
  default_opt.merge! opt
end  

ivix Sat 23 Apr 2011

May be i wrong asked question i mean how i can do it in Fantom language? I just can't found in documentation.

brian Sat 23 Apr 2011

I just want know is Fantom support named arguments for functions like Python?

There is no language support for named parameters. However, the work around is similar to the Ruby example above using a Map literals:

Void doIt(Str req, Str:Obj opts := [:]) { ... }


doIt("required", ["something":3, "another":true])

Login or Signup to reply.