Rapax 10 Posted November 23, 2014 I am embarrassed ask this,but Can someone explain to me why _count = count _multiArray1 select 0; // Output= 4? :confused: however much i read it I don't understand the Output 4 // Multi-dimensional array example _multiArray1 = [["Item1",1,2,3],["Item2",4,5,6]]; _count = count _multiArray1; // Output: 2 _count = count _multiArray1 select 0; // Output: 4 thank you Share this post Link to post Share on other sites
ProfTournesol 956 Posted November 23, 2014 Well, "_multiArray1 select 0" is first element of "_multiArray1" array, thus "["Item1",1,2,3]". This first element is also an array, composed of 4 elements. That's why the count command returns 4. Share this post Link to post Share on other sites
badluckburt 78 Posted November 23, 2014 Hi, multi-dimensional arrays can be a bit of a bugger when you first work with them. Try looking at your _multiArray1 like this: _multiArray1 = [ ["Item1",1,2,3], //First entry in the _multiArray1 array (index = 0) which is what you get when you _multiArray select 0; ["Item2",4,5,6] //Second entry in the _multiArray1 array (index = 1) which is what you get when you _multiArray select 1; ]; When you do _multiArray1 select 0;, you get the first entry from your main array: ["Item1",1,2,3]. As you can see, there are four items in that: Item1, 1, 2 and 3. That's why when you do count _multiArray1 select 0;, you get 4 back. It first selects the value from _multiArray1, which is the array with 4 items and then runs the count command on that value. I hope that explains things for you, what are you trying to do exactly? Share this post Link to post Share on other sites
Rapax 10 Posted November 23, 2014 LOL now I understand it thank you ProfTournesol Share this post Link to post Share on other sites
iceman77 18 Posted November 23, 2014 There are 4 elements in the selected array... eww.. Solved. Share this post Link to post Share on other sites
Rapax 10 Posted November 23, 2014 (edited) BadLuckBurt thank you for your explanation ! to be honest I find myself unable to do nothing, simply it makes me mad dont understand this concepts. Edited November 23, 2014 by Rapax Share this post Link to post Share on other sites
badluckburt 78 Posted November 23, 2014 You're welcome. After I posted I saw that Prof. Tournesol ninja'd me but I decided to leave it there anyway. And we've all been there. One thing that always helped me is breaking code down step by step. Sometimes things get a bit too abstract in the beginning when your brain first encounters a new situation and too many things happen at once. But the more you code, the less you need to do that because of the experience you gain :) Share this post Link to post Share on other sites
iceman77 18 Posted November 23, 2014 I would like to add that a good place to start would be Beginner's Guide To Arrays thread. It covers the very basics of arrays. Such as your OP question. Share this post Link to post Share on other sites
Rapax 10 Posted November 23, 2014 oh,that is good start, thank you for the link Iceman, It's so glad to ask this way! Share this post Link to post Share on other sites