x


Initialize multidimensional boolean array as all false Unity JS

When you initialize a multidimensional boolean array, is it possible to set them all to false, or would you have to loop through each value and assign to false?

more ▼

asked Dec 24 '10 at 08:38 AM

ina gravatar image

ina
3.3k 492 551 602

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

2 answers: sort voted first

Booleans are structs, which are always initialized to false anyway.

more ▼

answered Dec 24 '10 at 03:13 PM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

Debug.Log(multiDimBoolean.ToString() ) evaluates to null (i.e. no change from default gui text)

Dec 25 '10 at 05:25 AM ina
(comments are locked)
10|3000 characters needed characters left

You need to create the array first. When the array is created, all booleans have false value, as that is the types default. You don't need to set each individual boolean value, but you need to create the array.

more ▼

answered Jan 11 '11 at 06:42 PM

Statement gravatar image

Statement ♦♦
20.1k 35 70 175

(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:

x3463
x240
x29

asked: Dec 24 '10 at 08:38 AM

Seen: 1928 times

Last Updated: Dec 24 '10 at 08:38 AM