Created
April 10, 2012 19:07
-
-
Save koriroys/2353730 to your computer and use it in GitHub Desktop.
Stacks!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack | |
attr_accessor :stack | |
def initialize(input) | |
self.stack = input | |
end | |
def pop(*args) | |
return stack.pop if args.empty? | |
stack.pop.reverse # This shouldn't work. | |
end | |
def push(args) | |
stack.push(args) | |
true | |
end | |
def to_a | |
stack | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment