is there a way so i can write default argument in processing like c++?
in c++, for example:
void test(a=100)
{
ā¦ //some function that print value of a
}
so, when we call the function of test, if we dont passed value to that function, it will print 100
for example:
test() //print 100
test(200) //print 200
@kll demonstrated one approach ā method overloading, in which one signature has no arguments, and calls the second signature while supplying the default argument.
There are other approaches. One is to test for null and, if null, assign a default value. Then the no-arg form of a method call is foo(null). Another approach is to use varargs, and likewise check if each arg is present, and if not, assign its default. Another is to use the Builder pattern, in which each optional argument is a method.
A good summary of six approaches to default handling is in this answer: