How do i write the following java code in B4A? (please notice that it has the same function name but with different parameters within one class)
B4X:
public class whatever
{
static int make( int r, int g, int b, int a )
{
... function code...
}
static int make( int r, int g, int b )
{
... function code again...
}
} // end of class
B4A complains that it hase double function names - but in java that works.
As for now i made a function called "make4" and another "make3" to have a workaround for overloaded functions. Just wanted to know if i'm missing something. If that is not implemented is that feature planned?
Yes, it's called overloading. It's basically usefull if you want to add let's say 2 values (as integers) and somewhere else you need to add two floats. So you don't need to keep track of 2 different names (such as AddInt and AddFloat) you could just use Add no matter what you pass the function will work. (because if you pass float it will use the float function to add and therefore you don't lose the result because it's not cast to an int)