✅ Array look if in right order?
I have this array:
After that array, I have this:
Currently it looks if it's in the right order '1 2 3 4 5' (It's not at the moment, so it'll return false.)
But how can I make it look if it's in the right order '1 2 3 4'? It keeps returning false because it looks at all numbers in the array, not only the first 4. I tried changing 'numbers.Count()' to 4, and I also tried 'numbers.Count() - 1' but those aren't working.
5 Replies
numbers[0..4] or numbers.Take(4) depending on the type
(btw please use
.Length
instead of .Count()
)thank you! this works! :D
alright, why though? c:
Count()
has to loop over every element in the array to check how many there are. Length
is just a constant property of an array which returns its length.
So Count has to count the elements, while Length is just the length.thanks! :D