learn-co-curriculum / collections_practice_vol_2

More practice with iteration and nested data structures
Other
0 stars 5 forks source link

Issue with #first_wa #7

Closed m00se333 closed 5 years ago

m00se333 commented 8 years ago

I have an issue with the fourth test in this lab that requires one to create a method that returns the first element in an array beginning with "wa". I have a method that works out in irb and here it is:

def first_wa(array)
  array.find do |x|
     x.start_with("wa")
  end
end

Yet I am met with a method error in learn, check it out:

1) collections practice vol 2. #first_wa Return the first element that begins with the letters 'wa'
     Failure/Error: expect(first_wa(["candy", :pepper, "wall", :ball, "wacky"])).to eq("wall")
     NoMethodError:
       undefined method `start_with?' for :pepper:Symbol
     # ./collections_practice.rb:30:in `block in first_wa'
     # ./collections_practice.rb:29:in `each'
     # ./collections_practice.rb:29:in `find'
     # ./collections_practice.rb:29:in `first_wa'
     # ./spec/collections_practice_spec.rb:118:in `block (3 levels) in <top (required)>'

The issue is that I have used .start_with? in another method in this very same lab and passed that test. What's up?

maxwellbenton commented 5 years ago

Hi @m00se333,

Thank you for opening this issue and providing feedback. It looks from your code snippet that you may be missing the ? at the end of .start_with? which is likely the cause of this error:

def first_wa(array)
  array.find do |x|
     x.start_with("wa")
  end
end

You solution looks valid otherwise. As this appears to be related to the solution, I am going to close this issue.