Skip to content

Instantly share code, notes, and snippets.

Created December 25, 2015 11:21
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 anonymous/500eaa33f8b3162b5e77 to your computer and use it in GitHub Desktop.
Save anonymous/500eaa33f8b3162b5e77 to your computer and use it in GitHub Desktop.
class TodoList
attr_reader :name, :todo_items
def initialize(name)
@name = name
@todo_items = []
end
def add_item(name)
todo_items.push(TodoItem.new(name))
end
def contains?(name)
end
def find_index(name)
index = 0
found = false
todo_items.each do |item|
found = true if item.name == name
break if found
index += 1
end
if found
return index
else
return nil
end
end
end
In the TodoList class, fill in the contains? method so that it returns a boolean value if the todo items array contains an item with the name argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment