Welcome to the Treehouse Community
Looking to learn something new?
Help returning boolean values
def contains?(name) todo_items.include?(name) end
I'm getting an error message saying the contains? method is not returning a boolean value. I can't find my own error. Help is appreciated
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) return todo_items.include?(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
Maciej Czuchnowski36,440 Points
That is weird. I'm almost sure that I had similar code when doing this challenge a few weeks back and it worked. Other, more clumsy solutions don't work either.