Skip to content

Instantly share code, notes, and snippets.

@knehring

knehring/todo.rb

Created Aug 8, 2015
Embed
What would you like to do?
class ToDoList
def initialize
@itemList = []
end
def addItem(item)
@itemList.push(item)
end
def deleteItem(item)
@itemList.each do |key|
if key == item
@itemList.delete(item)
end
end
end
def viewList
@itemList.each do |item|
puts item
end
end
end
todo = ToDoList.new
todo.addItem("Cats")
todo.addItem("Dogs")
todo.viewList()
todo.deleteItem("Dogs")
todo.viewList()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment