turingschool / curriculum

Turing's main repository of tutorials and projects
385 stars 502 forks source link

clearer explanation #615

Closed jubalh closed 11 years ago

jubalh commented 11 years ago

In the EventManager file, in chapter "Moving Displaying Legislators to a Method" it is stated: "We want to extract our legislator names into a new method named legislators_by_zipcode which accepts a single zip code as a parameter and returns a comma-separated string of legislator names."

The code is like this:

def legislators_by_zipcode(zipcode)
  legislators = Sunlight::Congress::Legislator.by_zipcode(zipcode)

  legislator_names = legislators.collect do |legislator|
    "#{legislator.first_name} #{legislator.last_name}"
  end
end
#...
  legislators = legislators_by_zipcode(zipcode).join(", ")

Which is strictly speaking not the same. Nothing important though, just thought maybe this should be changed to be more precise.

Besides, the variable "legislator_names" is not necessary, is it? I am just starting out with ruby, and write this as I'm working my way through the (great!) tutorial :)

steveklabnik commented 11 years ago

Absolutely! That's why the variable is there: you'd end up using it to add the join.

Would you like to submit a fix so that you get credit?

jubalh commented 11 years ago

Sure! Will do it tomorrow.