Created
September 27, 2013 03:21
-
-
Save davidbella/6723735 to your computer and use it in GitHub Desktop.
Ruby: Conference listing and printing greetings
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
def print_names(names) | |
messages = [] | |
names.each do |name| | |
messages << "Hello, my name is #{name}" | |
end | |
messages | |
end | |
def assign_room_to_speakers(names) | |
assignments = [] | |
i = 1 | |
names.each do |name| | |
assignments << "Hello, #{name}! You'll be assigned to room #{i}" | |
i += 1 | |
end | |
assignments | |
end | |
def send_to_the_printers(speakers) | |
greetings = print_names(speakers) | |
puts greetings | |
assignments = assign_room_to_speakers(speakers) | |
puts assignments | |
end | |
speakers = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"] | |
send_to_the_printers(speakers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment