lastIndexOf

Returns the last index position of a specified element within a list, or -1 if the list does not contain the specified element.

Syntax:

$[ScriptVariable]::lastIndexOf(String str)

Parameters:

str (String): the list element to search for within the list.

Example:

The following example illustrates the syntax for the lastIndexOf list method (using the $recipients list variable created in the add example):

$recipients::add("Building 14")

$position = $recipients::lastIndexOf("Building 14")

$position2 = $recipients::lastIndexOf("This is not in the list")

print($position)

print($position2)

Output:

3

-1