Skip to main content

All Questions

7 votes
5 answers
6k views

Using a function's return value as an if condition, good practice?

Do you think it is a good practice to use function return values as if conditions? I'm coding in PHP atm but it holds for many other languages. if(isTheConditionMet($maybeSomeParams)) { } or $res = ...
guenis's user avatar
  • 179
5 votes
6 answers
4k views

Making Simple IF Statements Shorter

If we assume we have this little snippet of code: string str = "checked"; bool test1; if (str == "checked") { test1 = true; } else { test1 = false; } Is it bad practice to change a simple ...
Felix Weir's user avatar