I always thought the part between the curly braces were kind of like it's own little built in method
definition that just wasn't assigned a name, just like how a literal number or string can be defined
without a name. Therefore, I always looked at writing:
if( i > 0 )
{
print "Yippee!"
print "I'm so happy";
}
else
{
print "Aww...."
print "Go away now";
}
the same as:
void passCheckPositive()
{
print "Yipee!";
print "I'm so happy";
}
void failCheckPositive()
{
print "Aww";
print "Go away now";
}
if (i > 0)
passCheckPositive();
else
failCheckPositive();
Comments