Example:
Code: Select all
function WhatEver(int Param1, optional int Param2) {
if (IsMissing(Param2))
DoThis();
else
DoSomethingOther();
...
Code: Select all
function WhatEver(int Param1, optional int Param2) {
if (IsMissing(Param2))
DoThis();
else
DoSomethingOther();
...
0
is a bad default value for your optional parameter in that function, right?).Code: Select all
function WhatEver(int Param1)
{
WhatEverInternal(Param1, 1); //let's say you want "1" to be the default value instead
}
function WhatEverWithParam2(int Param1, int Param2)
{
WhatEverInternal(Param1, Param2);
}
function WhatEverInternal(int Param1, optional int Param2)
{
...
}
Code: Select all
function WhatEver(int Param1, optional coerce string strParam2) { // OFC call it with second param as int.
local int Param2;
if (strParam2 == "") // Param not set!
DoThis();
else
{
Param2 = int(strParam2);
DoSomethingOther(); // use Param2 here
}