Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack < Array
- def top
- self[-1]
- end
- def top=(v)
- super.pop
- super.push v
- end
- def pop(n = nil)
- return super.pop
- # e = []
- # puts n
- # n.times {
- # e.unshift super.pop
- # }
- # e
- end
- def get(n)
- res = []
- while n > 0
- res.push @data.pop
- n -= 1
- end
- res.reverse
- end
- end
- a = Stack.new [2, 3]
- print a.pop
Add Comment
Please, Sign In to add comment