small medium large xlarge

13 May 2012, 12:30
John McCormack (3 posts)

Hi, I’m looking at the example for the &&(“and”) and !(“not”) operators on page 58. The one that has:

i_am_chris = true i_am_purple = false …etc.

I’m not clear on what the && operaror is doing. The confusion stems from the 2nd & 3rd lines:

puts i_like_beer && i_eat_rocks puts i_am_purple && i_like_beer

I’m reading one of them as true && false, and the other as false && true, but I don’t understand why the result for both of them is false.

15 May 2012, 19:42
Dave Thomas (344 posts)

For an && expression to be true overall, both parts must be true.

I’m happy if I’m well rested AND I’m well fed

I’m only happy if both are true.

16 May 2012, 08:00
John McCormack (3 posts)

I get it now, thanks Dave.

You must be logged in to comment