Created
November 19, 2013 16:55
-
-
Save jli-hashrocket/7548574 to your computer and use it in GitHub Desktop.
mailing list with optional challenge completed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =begin | |
| salutations = [ | |
| 'Mr.', | |
| 'Mrs.', | |
| 'Mr.', | |
| 'Dr.', | |
| 'Ms.' | |
| ] | |
| =end | |
| salutations = [ | |
| ['Mr.', 'Mrs.'], | |
| 'Mrs.', | |
| ['Mr.', 'Mrs.'], | |
| ['Dr.'], | |
| 'Ms.' | |
| ] | |
| first_names = [ | |
| 'John', | |
| 'Jane', | |
| 'Sam', | |
| 'Louise', | |
| 'Kyle' | |
| ] | |
| last_names = [ | |
| 'Dillinger', | |
| 'Cook', | |
| 'Livingston', | |
| 'Levinger', | |
| 'Merlotte' | |
| ] | |
| addresses = [ | |
| '33 Foolish Lane, Boston MA 02210', | |
| '45 Cottage Way, Dartmouth, MA 02342', | |
| "54 Sally's Court, Bridgewater, MA 02324", | |
| '4534 Broadway, Boston, MA 02110', | |
| '4231 Cynthia Drive, Raynham, MA 02767' | |
| ] | |
| contacts = salutations.zip(first_names,last_names,addresses) | |
| contact_hash = {} | |
| contacts.each do |contact| | |
| contact_hash[:contact] = contact | |
| title = contact_hash[:contact][0].is_a?(Array) ? contact_hash[:contact][0].join(" and ") : contact_hash[:contact][0] | |
| puts title + " " + contact_hash[:contact][1] + " " + contact_hash[:contact][2] | |
| puts contact_hash[:contact][3] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Slightly longer, but I think refactoring the last few lines to read this way is more readable: