NAME

Squirrel::Template::Expr::WrapArray - provide virtual methods for arrays


SYNOPSIS

  somearray.size
  sorted = somearray.sort()
  sorted = somearray.sort(key)
  reversed = somearray.reverse
  joined = somearray.join()
  joined = somearray.join(":")
  last = somearray.last
  first = somearray.first
  first = somearray.shift # modifies somearray
  somearray.push(avalue);
  last = somearray.pop # modifies somearray
  somearray.unshift(avalue);
  somearray.is_list # always true
  somearray.is_hash # always false


DESCRIPTION

This class provides virtual methods for arrays (well, array references) in the Squirrel::Template manpage's expression language.


METHODS

size

The number of elements in the list.

sorted()

The elements sorted by name.

sorted(fieldname)

The elements sorted as objects calling fieldname.

reversed

The elements in reverse order.

join()

A string with the elements concatenated together.

join(sep)

A string with the elements concatenated together, separated by sep.

last

The last element in the array, or undef.

first

The first element in the array, or undef.

shift

Remove the first element from the list and return that.

push(element,...)

Add the given elements to the end of the array. returns the new size of the array.

pop

Remove the last element from the list and return that.

unshift(element,...)

Add the given elements to the start of the array. returns the new size of the array.

expand

Return a new array with any contained arrays expanded one level.

  [ [ [ 1 ], 2 ], 3 ].expand => [ [ 1 ], 2, 3 ]
set(index, value)

Set the specified index in the array to value. Returns value.

is_list

Test if this object is a list. Always true for a list.

is_hash

Test if this object is a hash. Always false for a list.

is_code

Test if this object is a code object. Always false for a list.


SEE ALSO

the Squirrel::Template::Expr manpage, the Squirrel::Template manpage


AUTHOR

Tony Cook <tony@develop-help.com>