Named parameters: Difference between revisions

Content added Content deleted
No edit summary
Line 813: Line 813:
CreatePet{name='Rex',species='Dog',breed='Irish Setter'}
CreatePet{name='Rex',species='Dog',breed='Irish Setter'}
--position does not matter here.
--position does not matter here.
</lang>

=={{header|M2000 Interpreter}}==
We can use named parameters for modules only. Modules are like functions but can't be called from expressions. We can use current stack to return values using Push statement. Here we define type and we set values to make them optionals.

<lang M2000 Interpreter>
module namedparam (x as decimal=10, y as integer=50) {
Print type$(x), x
Print type$(y), y
}

namedparam 10, 20
namedparam ?, ?
Push 1, 2 : namedparam
Stack New {
\\ it is empty
namedparam
}
namedparam %y=500
namedparam %x=20
namedparam %x=1, %y=1
</lang>
</lang>