Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
So every kid is on the naughty-list? Guess that explains why the parents have to take care of the presents
-
oldfrizt787y@DjSall @Krokoklemme no the return ends the function. After a nice child the function ends with the return and skip the naughty part.
-
@samfreeman05 first and foremost: weird branching
Second: return in a void method? dafuq -
@samfreeman05 my condolences. Well, I guess over time you get used to that stuff
-
@Krokoklemme what do you think return is ? you think it's only used to return a value ?
-
luaq35937ySorry if this wasn't clear. I didn't write the function down, but I'd expect that if you are on a developer app, you know what return does.
-
luaq35937yThink of it like this. If that were a for or while statement, return acts just as break.
-
luaq35937y@ssync no matter if it is a void or not. As soon as return is called, it stops the function because it has already returned the value it was running for in the first place. But in this case, because it was a void, we return nothing, pretty much saying the function has done it's task.
-
DjSall15617y@oldfrizt thanks for explaining. Never seen it used in my main languages, excuse my confusion...
Is Santa coming to your house? Use my "advanced" algorithm to find out.
Person kid = getKidByName("yourName");
FatGuy santa = new FatGuy("santa");
if(!kid.wasNaughty()){
System.out.println("Good child");
santa.sendGift(kid, "train");
return;
}
System.out.println("You're on the naughty list");
santa.sendGift(kid, "coal");
rant