Jump to content

Named parameters: Difference between revisions

no edit summary
No edit summary
Line 813:
CreatePet{name='Rex',species='Dog',breed='Irish Setter'}
--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>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.