How could I make this shorter and extendable:
def overview
puts "All As:"
for f in @a
puts f
end
puts "\n"
puts "All Bs:"
for f in @b
puts f
end
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
can we written
In the general case, when you want to do something with several arrays you can put the arrays into an array and then use
eache.g.and once you get onto doing something more complicated than just printing out the values it makes sense to use the extract method refactoring on the operation you’re performing e.g.
Finally, if you need to keep descriptive labels (“All As” etc.) you can use a hash: