x


In Javascript, can I reverse a boolean as so: boolean = !boolean

Hello, I'm trying to reverse a boolean using testVar = !testVar; and it isn't working. Is this possible in UnityScript (Javascript)? If not, is there a somewhat similar way to switch between true or false, or do I have to use an if statement?

Thanks

more ▼

asked Jan 03 '11 at 12:54 AM

Socapex gravatar image

Socapex
57 5 7 15

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Yes, but you can't name a variable var. It's a keyword.

more ▼

answered Jan 03 '11 at 01:03 AM

Jessy gravatar image

Jessy
15.6k 72 95 196

It was just for the example :) I'll change it though. This means my problem is somewhere else, thanks a lot for the tip.

Jan 03 '11 at 01:04 AM Socapex

it doesn't matter, as long as the v is capital, it won't recognize it, allowing you to say stuff like: fireVar or liteVar but you can't say test var.

Jan 03 '11 at 01:44 AM Jesus_Freak
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x240
x39
x36
x2

asked: Jan 03 '11 at 12:54 AM

Seen: 3229 times

Last Updated: Jan 03 '11 at 01:05 AM