Skip to content

Conversation

@noahpatterson
Copy link

I want to be able to do the commented version above the uncommented 'roll_call' method, but I am not sure how. That 'include?' bit may be wrong as well. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to do this, you could convert the string "senior" to a method senior? and reduce the line count.

def roll_call(students, grade)
  puts "#{grade.capitalize}:"
  students.select { |student| student.send("#{grade}?".to_sym}.each do |stu|
    puts "* #{stu}"
  end
end

@jwo
Copy link
Member

jwo commented Nov 26, 2013

I think you were SO CLOSE on the commented method. Let me know if it makes any sense.

I created an example fiddle for you: http://rubyfiddle.com/riddles/09598/2

class SaysHello
  def speak
    "Hello!"
  end
end

speaker = SaysHello.new
puts speaker.speak
puts speaker.send(:speak)
puts speaker.send("speak".to_sym)

@noahpatterson
Copy link
Author

Fixed, love the send and to_sym! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants