# Get index of last true value of array in Julia | Array findlast() Method

• Last Updated : 23 Mar, 2020

The `findlast()` is an inbuilt function in julia which is used to return the index or key of the last true value in the specified array. Here values of index or key start from 1 i.e, for index of 1st element is 1, index of 2nd element is 2 and so on.

Syntax:
findlast(A)
or
findlast(predicate::Function, A)

Parameters:

• A: Specified array
• Predicate Function: Determines whether something is true or false based on the specified arguments

Returns: It returns the index or key of the last true value in the specified array.

Example 1:

 `# Julia program to illustrate ``# the use of Array findlast() method``  ` `# Finding index of last true value from ``# the 1D array A``A ``=` `[false, true, true, false]``println(findlast(A))``  ` `# Finding index of last true value from ``# the 2D array B of size 2 * 2``B ``=` `[false false; true false]``println(findlast(B))``  ` `# Finding index of last true value from ``# the 3D array C of size 2 * 2*2``C ``=` `cat([false false; true false], ``        ``[false true; true false],``        ``[true false; true true], dims ``=` `3``)``println(findlast(C))`

Output:

Example 2:

 `# Julia program to illustrate ``# the use of Array findlast() method``  ` `# Finding index of last even value from ``# the 1D array A``A ``=` `[``1``, ``2``, ``5``, ``6``]``println(findlast(iseven, A))``  ` `# Finding index of last even value from ``# the 2D array B of size 2 * 2``B ``=` `[``3` `5``; ``6` `7``]``println(findlast(iseven, B))``  ` `# Finding index of last even value from ``# the 3D array C of size 2 * 2*2``C ``=` `cat([``1` `2``; ``3` `4``], [``5` `6``; ``7` `8``], ``        ``[``9` `10``; ``11` `12``], dims ``=` `3``)``println(findlast(iseven, C))`

Output:

My Personal Notes arrow_drop_up