views:

114

answers:

5
if(metres >= 0) return true;
else return false;

Can I do this with a single calculation? (ignoring the ternary operator)

+2  A: 
return (metres >= 0);
codaddict
+5  A: 
return metres >= 0;
willcodejavaforfood
+1 because you do that for food.
+1. Because only you got rid of those useless parenthesis. Others might got this habit from programming Lisp, but I doubt it.
Adeel Ansari
LOL - Cheers guys :)
willcodejavaforfood
Not only Lisp. Pascal/Delphi programmers have to use parenthesis if some condition is more complicated. Code like: `if a > 0 and b > 0 then ...` does not compile :(
Michał Niklas
+2  A: 

return (metres >= 0);

Michał Niklas
+10  A: 
return (metres >= 0);
Andriy Sholokh
+1, because you need it most :)
Michael Borgwardt
You are missing a ;
:) Thank you, Michael Borgwardt! :)
Andriy Sholokh
user483085, thanks for comment. fixed.
Andriy Sholokh
+1  A: 

Does

return(meters>=0); 

work?

Jaydee