# To be not, or not to be not?

**URL:** <https://www.ruby-forum.com/t/to-be-not-or-not-to-be-not/149267>\
**Category:** Ruby\
**Created:** [September 23, 2008, 6:05am UTC](https://www.ruby-forum.com/t/to-be-not-or-not-to-be-not/149267 "2008-09-23T06:05:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubyfreak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rubyfreak](https://www.ruby-forum.com/u/rubyfreak)\
**Post date:** [September 23, 2008, 6:05am UTC](https://www.ruby-forum.com/t/to-be-not-or-not-to-be-not/149267/1 "2008-09-23T06:05:43Z")

</div>

That is not the question

Code in question:

module AuthenticatedSystem  
protected

# Returns true or false if the user is logged in.

```
# Preloads @current_user with the user model if they're logged in.
def logged_in?
  !!current_user
end

```

…

Is !! as simple as it looks, or does it have meaning beyond a double  
negative? Google doesn’t recognize !! in a search.

I see it as “Not (current\_user == Nil)”

…

---

<div class="post-metadata">

**Author:** ![rubyfreak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rubyfreak](https://www.ruby-forum.com/u/rubyfreak)\
**Post date:** [September 23, 2008, 6:58am UTC](https://www.ruby-forum.com/t/to-be-not-or-not-to-be-not/149267/2 "2008-09-23T06:58:21Z")

</div>

On Sep 22, 11:05 pm, Ruby F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is !! as simple as it looks, or does it have meaning beyond a double  
> negative? Google doesn’t recognize !! in a search.

It’s as simple as it looks, which is up for debate. The point of the  
double negative is to concisely turn any into a boolean. !! will  
always result in either true or false.

See [http://github.com/ymendel/truthy/tree/master/lib/truthy.rb](http://github.com/ymendel/truthy/tree/master/lib/truthy.rb) (and  
the spec at  
[http://github.com/ymendel/truthy/tree/master/spec/truthy\_spec.rb](http://github.com/ymendel/truthy/tree/master/spec/truthy_spec.rb)  
if you’re interested).

---

<div class="post-metadata">

**Author:** ![rubyfreak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rubyfreak](https://www.ruby-forum.com/u/rubyfreak)\
**Post date:** [September 23, 2008, 10:04am UTC](https://www.ruby-forum.com/t/to-be-not-or-not-to-be-not/149267/3 "2008-09-23T10:04:36Z")

</div>

Ruby F. wrote:

> I see it as “Not (current\_user == Nil)”

In fact, it is “Not (current\_user == Nil Or current\_user == False)”
