Boolean operators

Hey,

I have seen several times that it is recommended to use &&/|| for
boolean expressions, and/or for control flow. E.g.:

Use &&/|| for boolean expressions, and/or for control flow. (Rule of
thumb: If you have to use outer parentheses, you are using the wrong
operators.)

boolean expression

if some_condition && some_other_condition
do_something
end

control flow

document.saved? or document.save!

It is to prevent issues with precedence. Opinions?

ps - Do we have a style guide?

LZ

··· -- Later,

Lukas “lzap” Zapletal
irc: lzap #theforeman

>
> Hey,
>
> I have seen several times that it is recommended to use &&/|| for
> boolean expressions, and/or for control flow. E.g.:
>
> https://github.com/bbatsov/ruby-style-guide
>
> Use &&/|| for boolean expressions, and/or for control flow. (Rule of
> thumb: If you have to use outer parentheses, you are using the wrong
> operators.)
>
> # boolean expression
> if some_condition && some_other_condition
> do_something
> end
>
> # control flow
> document.saved? or document.save!
>
> It is to prevent issues with precedence. Opinions?

Indeed it does: http://phrogz.net/ProgrammingRuby/language.html#table_18.4

-d

>
> ps - Do we have a style guide?
>
> LZ
>
> –
> Later,
>
> Lukas "lzap" Zapletal
> irc: lzap #theforeman
>
> –
> You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.

··· On 6 May 2013 08:10, "Lukas Zapletal" wrote: > For more options, visit https://groups.google.com/groups/opt_out. > >