Кто-нибудь знает умный способ получить последний элемент массива в манифесте марионетки?
Существующий код выглядит так:
class nginx {
define vhost {
#-----
# Init vars
#-----
$app_parts = split($name, '[_]')
# I can access any element using numeric notation
notify { "Element: ${app_parts[0]}": }
# How do I access the last element?
Arrays support negative indexing, with -1 being the final element of the array:
так..
$foo = [ 'one', 'two', 'three', 'four', 'five' ]
notice( $foo[-1] )
# 'five'