Why is @ad not []?
Why would it be? Your code is extremely basic, and it says “if @ad has less than two items, set it to an empty array”. As you clearly show, @ad doesn’t have less than two items, it has three items. Does three seem less than two to you?
If you’re tying to find the number of unique items, you need ot use .uniq
, but it still won’t be less than two, it will be exactly two, and so you still won’t enter the if
condition.
0
solved Array if size over 2 set array to [] [closed]