Bang! Bang! your dead

I found an obscure bug today, a typo no less, but Im getting ahead of myself.
It turns out that C# allows you to use multiple not operators (!).

So:  true == !!true and false == !!false

Why you would ever want to use this is beyond my small level of comprehension, but it made finding my bug a little harder.

if(!X and !!Y) then do something

it turns out it was meant to be
if(!X and !Y) then do something

The double bang is easily glossed over as your eyes are looking for its presence not checking there is a correct count of bangs.

 

Advertisements

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: