Skip to content

[BUG] arrayLastIndexOf() not searching from the end #3873

@ChadJeffreyAnderson

Description

@ChadJeffreyAnderson

Make sure you're on the latest stable or beta build

  • I have tested this on the latest stable or beta release

Is this a bug in companion itself or a module?

  • I believe this to be a bug in companion and not a specific module

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

arrayLastIndexOf( val, find, offset ) seems to be searching backwards from index 0 by default, rather than the end of the array. I have to set the offset to length(array) to have it actually search from the end.

Steps To Reproduce

  1. In an expression, set up an array with two of the same value
  2. Pass it to arrayLastIndexOf()

    array = [1,1,1]
    arrayLastIndexOf(array, 1)

  3. See that it returns 0 only if the find value is in index 0, and -1 in all other cases

Expected Behavior

The function finds the index of the last occurrence of a value within the provided array without needing to specify the end of the array as the starting index.

Environment (please complete the following information)

- OS: Win 11 23H2
- Browser: Edge 143
- Companion Version: 4.2.2

Additional context

The documentation for arrayLastIndexOf() does specify that "The beginning is position 0", which seems to be true.
However, the documentation for lastIndexOf() also says this and that function does not share this behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions