!0 is 1

!0 === 1

Only tested this in Javascript and Ruby, but I bet it works in C like it did in Javascript.

mars@scheherazade:~$ js
Rhino 1.7 release 2 2010 01 20

js> 3+!0
4

Ruby is safeguarded against such hijinks:

mars@scheherazade:~$ irb
irb(main):001:0> 3+!0
TypeError: false can't be coerced into Fixnumfrom (irb):1:in `+'from (irb):1from :0

Advertisements

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: