Just curious about little something that came to mind, but I haven't been able to find an answer to it by searching. Is it possible to return an instance with the return
keyword and also set a variable within that instance in the same line?
For example, I tried doing:
public Person randomPersonHeight(Person person){
Random r = new Random();
return person.height = 5+(r.nextFloat()*1.5);//Imperial Measurements baby!
}
I wanted to set the persons height AND return the person in one swoop. But no surprise that didn't work. Of course it isn't important that I can do it in the single line. And, just wont stand for anything less!.. But, I found myself wanting to know there was any expression or different format that would make it possible.