I am looking for a more efficient way to perform the following action, where I am appending the return value of a method to an array. However if the return is null i want to perform another action and not change the array.
Object[] myVal = new Object[10];
Object temp;
temp = myFunction();
if(temp != null) {
myVal[count++] = temp;
} else {
System.Exit();
}
Where I want to assign a variable to the return of a method, but provide an 'inline' check to carry out another action if the value returned is null.
Something like:
myVal = (myFunction() != null) ? [output of expression]: System.Exit();
Is there any method like this?
new Objectpart.