Named parameters: Difference between revisions
Content added Content deleted
(Omit Axe) |
|||
Line 960: | Line 960: | ||
e1 e2 |
e1 e2 |
||
k1 k2</pre> |
k1 k2</pre> |
||
=={{header|Phix}}== |
|||
Phix supports named and optional parameters.<br> |
|||
Optional parameters are specified simply by providing a default, any non-defaulted parameters must occur before (to the left of) any defaulted parameters.<br> |
|||
Named parameters can be given in any order, but must be grouped together after (to the right of) any non-named parameters. |
|||
<lang Phix>global function timedelta(atom weeks=0, atom days=0, atom hours=0, atom minutes=0, atom seconds=0, atom milliseconds=0, atom microseconds=0) |
|||
-- can be invoked as: |
|||
constant fourdays = timedelta(days:=4) |
|||
-- fourdays = timedelta(0,4) -- equivalent |
|||
-- **NB** a plain '=' is a very different thing |
|||
constant oneday = timedelta(days=1) -- equivalent to timedelta([weeks:=]iff((equal(days,1)?true:false)) |
|||
-- - with an error if no local variable days exists. |
|||
constant shift = timedelta(hours:=hours) -- perfectly valid (param hours:=local hours) |
|||
-- timedelta(0,hours:=15,3) -- illegal (it is not clear whether you meant days:=3 or minutes:=3)</lang> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |