Array Index

noun

say it: “uh-RAY IN-deks” /əˈreɪ ˈɪndɛks/

A number that says where an item sits in a list, starting from 0 for the first item.

What is an array index in PowerShell?

An array index is an item's position in a list, counted from 0 and written in square brackets after the array's name. [0] is the first item, [1] the second, and [-1] the last, so you can reach the end without counting.

$machines = 'kettle-bot', 'oil can', 'clock', 'gearbox', 'bell'
$machines[0]     # kettle-bot
$machines[-1]    # bell

In a sentence

  • “The array index 0 gave the first machine on the list, the kettle-bot.”
  • “Ada used the array index -1 to get the last job of the day.”

Level: Apprentice · More PowerShell terms at this level

Updated

In other subjects