Method: Array#peek
- Defined in:
- lib/core/facets/array/pull.rb
#peek(i = 0) ⇒ Object
Peek at the top of the stack (the end of the array).
a = [1, 2, 3]
a.peek #=> 3
a #=> [1, 2, 3]
Or provide an index to inspect the array from back to front.
14 15 16 17 |
# File 'lib/core/facets/array/pull.rb', line 14 def peek(i=0) i = -(i + 1) fetch(i) end |