Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Booleans Build a Simple Todo List Program Returning Boolean Values: Part 2

alborz
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
alborz
Full Stack JavaScript Techdegree Graduate 30,885 Points

Can't get this Ruby boolean challenge to work.

Hi!

So I'm stuck. Not sure what else to try besides something relatively close to what I have:

 def contains?(name)
    todo_items.each do |item|
      if todo_items.item == name
        return true
      end
    end
  end

Any push in the right direction is appreciated!

1 Answer

You'll need to return false in cases where name is not one of the todo items; that can be done by adding return false as the last line of the method.

Also where you're checking to see if name is the current item in the loop you should be looking at item.name not todo_items.item as item is the current element you're inspecting:

if item.name == name