Skip to content

Instantly share code, notes, and snippets.

@tooky
Created June 26, 2014 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tooky/f11088796979b7eabdfd to your computer and use it in GitHub Desktop.
Save tooky/f11088796979b7eabdfd to your computer and use it in GitHub Desktop.
Challenge made by @coreyhaines on the http://kickstartacademy.io podcast.
class Stack
def empty?
true
end
def push(element)
@empty = false
end
end
def assert(expected, actual, msg="FAIL!")
if expected != actual
raise "Failed test. #{expected} should have been #{actual}"
end
end
# a new stack is empty
s = Stack.new
assert(true, s.empty?)
# a stack is not empty after I push
s = Stack.new
s.push 5
if false != s.empty?
raise "Stack should not have been empty"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment