x


What's the proper way to see if a Vector3 List index is null?

I'm actually using a jagged list of Vector3's, so I don't always know if the second dimension is null or not.

Testing for Vector3 == null obviously won't work, because it's initialized as Vector3.zero.

So my questions is- what's the proper way to test an index of a list to see if it contains a Vector3? I figure I could always catch the ArgumentOutOfRangeException, but that seems hacky and wrong.

Any ideas?

more ▼

asked Jun 12 '11 at 08:00 PM

testure gravatar image

testure
4.2k 20 25 48

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

1 answer: sort voted first

If you worry about "counting too far", you could always check against the length of each of the arrays in your jagged array. If the index is greater than or equal to the array's length, don't index into it, I guess?

more ▼

answered Jun 12 '11 at 08:10 PM

CHPedersen gravatar image

CHPedersen
6k 13 22 61

perfect. Don't know why I didn't think of that- my head is swimming with all of the recursive stuff I've been doing today ;)

Jun 12 '11 at 08:14 PM testure
(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:

x575
x356
x128
x32
x6

asked: Jun 12 '11 at 08:00 PM

Seen: 848 times

Last Updated: Jun 12 '11 at 08:14 PM