unity named parameter code example

Example: unity named parameter

// required = 3, optValue = "test", optNum = 4
ExampleMethod(3, optNum: 4);
// required = 2, optValue = "foo", optNum = 42
ExampleMethod(2, optValue: "foo");
// required = 6, optValue = "bar", optNum = 1
ExampleMethod(optNum: 1, optValue: "bar", required: 6);

Enables you to pass the argument to the function by associating the parameter’s
name No needs for remembering the parameters position that we are not aware of
always. No need to look the order of the parameters in the parameters list of
called function. We can specify parameter for each arguments by its name.

Tags:

Misc Example