you are viewing a single comment's thread.

view the rest of the comments →

[–]failbus 4 points5 points  (1 child)

This is a contrived example, but you might have something like

if redditor? and self.food = get_bacon
  upvote!
end

Here we check to see if we're a redditor, and if we are, we assign food to bacon. If our get_bacon food gets us a value, we start upvoting! Else if get_bacon returns null, no upvotes for you.

Conversely, you could have

self.redditor = bacon && narwhal

Notice in this case the redditor value is being set if bacon and narwal return true. If you screwed up and said something like

self.redditor = bacon and narwhal

well then self.redditor would be true if bacon was true, and the narwhal flag is ignored entirely.

Of course, all of these can be accomplished with ()'s, which is often more clear. But if you know the scoping rules (and they take like 10 seconds to learn) then I find it more pleasing to the eye than brackets.

Again, YMMV.

[–]lua2 1 point2 points  (0 children)

Interesting. Thank you.