Onelinerhub / onelinerhub

Thousands of code solutions with clear explanation @ onelinerhub.com
https://onelinerhub.com
MIT License
802 stars 159 forks source link

Create array_last_element.md #1910

Closed ErikThiart closed 1 year ago

ErikThiart commented 1 year ago

This code first retrieves the keys of the $arr array using the keys property, then uses the select cmdlet with the -last 1 parameter to retrieve the last key of the array. Finally, it retrieves the value at that key from the $arr array and assigns it to the $last variable.

nonunicorn commented 1 year ago

https://onelinerhub.com/powershell/array_last_element