Arrays.FirstIndex Was that really necessary

Hello,
Arrays always start at 0. Why do I also need FirstIndex?
I’d rather have FirstObject and LastObject available.

What is the difference if it returns array(0) ?

1 Like

i think .FirstIndex for consistent.

I’d rather have FirstObject and LastObject available.

if you speak about objects its better to use for each

Arrays always start at 0
some languages use
0 to count-1
others
1 to count

1 Like

We have MyArray.Pop to get the last item and remove it in the same instruction. I miss MyArray.Shift to get and remove the first item.

2 Likes

On first glance I missed the “f” in shift, but it still made perfect sense to me :slight_smile:

4 Likes

Some say your humor is a bit dark sometimes. :face_with_hand_over_mouth:

1 Like

:smiley: I don’t understand as there is the f in my post. Or a moderator edited my comment?

That’s a very polite way of saying I have a childish sense of humor.

You did nothing wrong, it was simply my mind mis-reading array.shift as an alternative (and rude) word for feces, but not seeing anything wrong with it and actually accepting this as a means for extracting the first item and then “dumping” it from an array.

I use this technique a lot with many asynchronous callbacks from Apple’s API, but I’ve never needed to use array.pop.

Perhaps I should log a feedback request for array.shift, with an f in the name.

:slight_smile:

I add a feature request feedback://showreport?report_id=67306 .

1 Like

What I do is myArray.AddAt(0), instead of Add, so I can myArray.Pop :neutral_face:

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.