Learn Ruby
What is nil

nil is like false

We have seen that if condition works on true and false value.

In Ruby nil is like false.

In the above case can_vote has nil value and Ruby executed else part of the code.

Ruby treats both false and nil similar to false and we call it falsy. Opposite of falsy is truthy. Ruby treats everything else as truthy. It means any string or any number are truthy.

As we can see above Ruby treated s as truthy.

In summary false and nil are falsy. Rest everything else is truthy.