Tag:

Short-Circuiting Conditionals and Ruby

Update: It has been pointed out to me, that my original understanding of the problem I was having in ruby was incorrect. Both sets of logical operators do short-circuit. The problem that I was having, and didn’t really illustrate in the examples, was caused by the fact that ‘or’ and ‘and’ have a lower precedence than ‘||’ and ‘&&’. Weird. Thanks Igal.

I often read blog entries about things that I think are very simple, or straight forward, or common knowledge; basically topics that I would never have imagined writing an entry about. I struggle to come up with blog entries sometimes, as it is evident by this blog.

I am developing a ruby on rails app as a side project, which I will write about here shortly, and came across a bug that stumped me, until I figured out that the ruby logical operators ‘or’ and ‘and’ do not short-circuit, but the operators ‘||’ and ‘&&’ do. “Ah ha, here is a topic I can blog about”, I thought to myself.

Read the rest of this entry »

Tags:

,

Comments:

No Comments