Truth or Dare!

Boolean

Ok,something I can get a grasp on pretty easily! BOOLEAN!
Don't be scared of this just because it looks frightening.It's actually quite simple in Ruby. Keep in mind there are basic rules to the concept. Something is either false (falsey is how we say it), or true (truthy is how we say this one).
Two things to remember about falsey:
1) false is falsey
2) nil is falsey
THAT'S IT!
Everything else is truthy!
The rule of &&,
&& moves forward to the next thing as long as the previous object is truthy.
The rule of ||,
|| moves forward to the next thing as long as the previous object is falsey.
If I said:
"table" && false what would the result be? table or false?
If you said false you would be right. Why? Let's look at it this way.
("table" &&) false--- is table true according to the rule of &&? It is so we move on to the next thing which is false.
How about if I said:
"table" || false what would the result be? ........."table", right?! Because if table were false according to the rule of ||, we would have moved forward to false. But it was not false or nil so we stayed right at table.
Now this is no way to code of course but let's look at it in a different way. Ruby(<% if user_signed_in && user_signed_in.admin %>)
this is saying if the user is signed in proceed to the next thing which is to see if the admin is signed in. If so proceed, if not it will revert back to the last true statement.
Now there is another thing to remember, if there is a !, also know as BANG, in front of something it means the opposite of what it really is.
examples:
!water = false why? because water was true (not false or nil) until you place the !(BANG) in front of it which made it false.
!false = true get it? The opposite of false is true.
What do you suppose it would be if I did this:
!!true What is this, true or false? True because you changed it twice which put it back to it's original state.
Now this is just a way to grasp what Ruby is doing in real code. I hope this helps you think through boolean a little easier.