📜  unity 命名参数 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:57.254000             🧑  作者: Mango

代码示例1
// 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.