PHP has this, and I'm pretty sure C++ also has it for functions, where you can specify a default parameter value for a function so if it's not given in the function call, it takes a default value. Like in PHP, the syntax I believe is:
So, if you call the function using myFunction(), inside the function, $blah will have the value of "asdf". But, if you call it using myFunction("qwerty"), $blah takes on "qwerty". I tried using the same syntax in Java, and javac doesn't like it. Does anyone know what the correct syntax, if such a thing even exists, in Java is? Thanks.
BTW, if it matters, in my case, the parameter is a boolean and by default, i want it to be false unless true is passed in the method call.
PHP:
function myFunction($blah="asdf")
So, if you call the function using myFunction(), inside the function, $blah will have the value of "asdf". But, if you call it using myFunction("qwerty"), $blah takes on "qwerty". I tried using the same syntax in Java, and javac doesn't like it. Does anyone know what the correct syntax, if such a thing even exists, in Java is? Thanks.
BTW, if it matters, in my case, the parameter is a boolean and by default, i want it to be false unless true is passed in the method call.