Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add junior method and roll_call print method #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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!

def roll_call(students, grade)
puts "#{grade.capitalize}:"
if grade == "senior"
students.select { |student| student.senior? }.each do |stu|
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