From the archive

Boolean Algebra- Let's Talk About X Ba-by

Welcome to a land where 1 + 1 = 1.

In my last post, I talked about the +(OR) operator. This time, let's talk about x. Let me refresh your memory and remind you that values used in this algebra are 0(or false) and 1(or true) instead of actual numbers. In Boolean Algebra, the x operator stands for an INTERSECTION. An intersection is everything that is in the first class AND everything that is in the second class. This operator also holds true to the commutative property. It can be written like this H x M, M x H, HM, or MH.

Let's pretend we know a very fancy lady. She will not leave the house without her hair AND her makeup done. Let's say it's Sunday and she needs milk but she refuses to do her hair and her makeup. This means Hair = false(0), AND Makeup = false(0). If we put this into a Ruby expression, it would look like this...

```ruby if Hair (is true(1)) && Makeup(is true(1)) puts "I am on my way out to get milk." else puts "I wouldn't be caught dead looking like this!" end ```

The result is "I wouldn't be caught dead looking like this!"

Now let's pretend she started getting ready and got her Hair done,(Hair = true(1)) but did not do her Makeup(Makeup = false(0))

```ruby if Hair (is true(1)) && Makeup(is true(1)) puts "I am on my way out to get milk." else puts "I wouldn't be caught dead looking like this!" end ```

The result is "I wouldn't be caught dead looking like this!" since she does not have both of those things happening.

Now let's say that on Saturday she got a new lipstick and a new hair bow. She is ready to be seen looking fabulous. On Sunday, she just can not wait until Monday to get ready (This is how you can tell this story is complete fiction. :) ) and decides that even though it is Sunday, she is going to do her Hair(Hair = true(1))) AND Makeup(Makeup = true(1)).

```ruby if Hair (is true(1)) && Makeup(is true(1)) puts "I am on my way out to get milk." else puts "I wouldn't be caught dead looking like this!" end ```

Now the result is "I am on my way out to get milk."

Once again, as if that were not enough, here is a truth table to look at it a different way.

and_table

```ruby if "learned about OR" && "Learned about AND" puts "George Boole would be proud!" else puts "I need to re read these posts!" end ```

"George Boole would be proud!"