I am curious if APEX permits declaration of default arguments (or parameters if you will). When calling the method without specifying the value, method would be executed with the default value, otherwise with the value specified. I expect it would look somehow like this:
public String foo(String name, String greeting = 'Hello'){
return greeting + ' ' + name;
}
Then calling this twice
foo('John');
foo('John', 'Good Evening');
would give me
Hello John
Good evening John
Is this somehow possible to do in APEX out of the box, or do I have to, for example, define overload for the method like this?
public String foo(String name){
return foo(name, 'Hello');
}
public String foo(String name, String greeting){
return greeting + ' ' + name;
}