Named arguments

  1. 3 years ago


    20 Jun 2019 User since 2018
    Edited 3 years ago by Marc

    When you have a method with optional parameters:

    func Test(a = 1, b = 2) {} 

    and you only want to provide argument "b", then you have to do this:

    Test( , "value for b")

    This looks a bit messy imho.

    In other languages I've always used named arguments, when available there, like this:

    Test(b: "only value b")


    Test(b: "value b", a: "value a")

    NB: With named arguments, sequence doesn't matter.

    I personally find using named arguments, albeit more verbose (for some ...), gives better code readability and, as a bonus, is less prone to errors (if you f.e. use the wrong sequence).

  2. marco

    20 Jun 2019 Administrator User since 2016

    Hi @Marc yes I agree and named arguments are already 3/4 implemented so you can expect that feature in the near future.

or Sign Up to reply!