Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi all,
I want to pass optional/default parameter in apex method,same as java.
But it throws error.
Is there any special way to pass optional/default parameter in apex method?
Please help me.
Regards,
Manoj Jain
First of all... PLEASE SEARCH BEFORE POSTING (I found the answer within two seconds of doing so)
You can't using optional and default values in functions but you can use overloading.
eg.
public void foo(String xyz) { system.debug(xyz); } public void foo() { foo('FOOBAR'); } foo();
The above will print FOOBAR to the debug log.
If you still dont understand, google it.
First of all... PLEASE SEARCH BEFORE POSTING (I found the answer within two seconds of doing so)
You can't using optional and default values in functions but you can use overloading.
eg.
public void foo(String xyz) { system.debug(xyz); } public void foo() { foo('FOOBAR'); } foo();
The above will print FOOBAR to the debug log.
If you still dont understand, google it.
All Answers
First of all... PLEASE SEARCH BEFORE POSTING (I found the answer within two seconds of doing so)
You can't using optional and default values in functions but you can use overloading.
eg.
public void foo(String xyz) { system.debug(xyz); } public void foo() { foo('FOOBAR'); } foo();
The above will print FOOBAR to the debug log.
If you still dont understand, google it.