Question: I am getting a request from mobile app. They are sending a variable `isbookmarked` that can be either `1` or `0`. I am checking in if statement. 

```
if isbookmarked
  do something
else
  do something
end

```

The `else` part is never executed because `0` is not recognised as `false` 

How can I achieve this?

Answer: 
You can use this gem called [wannabe\_bool](https://github.com/prodis/wannabe_bool), you will get a `to_b` method which can convert almost everything to boolean, you can check the gem documentation for all the options available.

```
if isbookmarked.to_b
  do something
else
  do something
end

```

I have tried few of the things on console that might help you

```
2.0.0-p451 :002 > "1".to_b
 => true 
2.0.0-p451 :003 > "0".to_b
 => false 
2.0.0-p451 :004 > 1.to_b
 => true 
2.0.0-p451 :005 > 0.to_b
 => false

```

<https://github.com/prodis/wannabe_bool>

Hope that helps!
You can also use [`zero?`](https://ruby-doc.org/core-1.9.3/Numeric.html#method-i-zero-3F) to check whether the value is zero or not. But there is no special method to check 1 only way `isbookmarked == 1`

```
if isbookmarked.zero?
  do something
else
  do something
end

```