All pastes #1753556 Raw Edit

Someone

public ruby v1 · immutable
#1753556 ·published 2010-01-16 14:30 UTC
rendered paste body
class Stack  def initialize()    @stack = []  end  def empty?()    @stack.empty?  end  def length()    @stack.length  end  def push(value)    @stack.push(value)  end  def pop()    @stack.pop()  end  def peek()    @stack.last  end  def dup()    @stack.push(@stack.last)  end  def swap()    @stack[@stack.length - 1], @stack[@stack.length - 2] = @stack[@stack.length - 2], @stack[@stack.length - 1] if @stack.length >= 2  endend