Named Arguments
Call functions with named parameters for clarity and flexibility.
Syntax
wyn
fn create_user(name: string, age: int, role: string = "member") -> string {
return name + " (" + role + ", " + age.to_string() + ")"
}
// Positional (existing)
create_user("Alice", 30, "admin")
// Named — any order
create_user(name: "Alice", age: 30, role: "admin")
create_user(age: 30, name: "Alice") // defaults fill 'role'
// Reorder for readability
create_user(role: "admin", name: "Bob", age: 25)Rules
- Named args can be in any order
- Unspecified params use their default values
- Mix positional and named: positional args fill left-to-right, named args fill by name
See Also
- Functions — function definition and calling