How to pass arguments to the method in random order?

  • 2
    Why do you need it? - Matty
  • five
    Using their names? myMethod(value2: "4", value1: "1"); - Wiktor Stribiżew
  • 2
    Then see point 1: Why do you need it? - Wiktor Stribiżew
  • one
  • 3
    @AlexanderPuzanov: And how, without names, then the compiler will understand which one is which? For example, if you have two integer arguments. - VladD

1 answer 1

Use named arguments.

 new string('A', 2); 

tantamount to

 new string(count: 2, c: 'A'); 
  • one
    It turned out that he wants no names :-) - Grundy
  • one
    @Grundy: Let him then add to the question :) - VladD