You are here

public function ctools_math_expr_stack::last in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/math-expr.inc \ctools_math_expr_stack::last()

"Peek" the stack, or Return a value from the stack without removing it.

Parameters

int $n: Integer indicating which value to return. 1 is the topmost (i.e. the value that pop() would return), 2 indicates the next, 3 the third, etc.

Return value

mixed|null A value pushed onto the stack at the nth position, or NULL if the stack was empty.

File

includes/math-expr.inc, line 877
=============================================================================.

Class

ctools_math_expr_stack
Class implementing a simple stack structure, used by ctools_math_expr.

Code

public function last($n = 1) {
  return !empty($this->stack[$this->count - $n]) ? $this->stack[$this->count - $n] : NULL;
}