Created
December 25, 2015 11:21
-
-
Save anonymous/500eaa33f8b3162b5e77 to your computer and use it in GitHub Desktop.
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 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