Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
eagledude4

Adding player name to an array

Recommended Posts

CarLicenseArray = [];
CarLicenseArray = CarLicenseArray + (name player);

Returns generic error.

Share this post


Link to post
Share on other sites
CarLicenseArray = [];
CarLicenseArray = CarLicenseArray + [name player];

Share this post


Link to post
Share on other sites

When adding to an array the value you're adding with needs to be in the form of an array, I didn't understand this at first either. The result will always result with one less set of square brackets (As in, if you add [[]] what will really be added is []) . So..

_arr = [];
_arr = _arr + [[1,10],[2,20]];

The value for _arr would actually be [[1,10],[2,20]] instead of [[[1,10],[2,20]]] as you would think, therefore using no brackets will make for an error. (Same applies for strings aswell, makes sense if you think about it but kind of confusing as the concept is adding.)

Share this post


Link to post
Share on other sites

I didnt notice the difference at first, but what you said makes sense. Thanks guys.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×