Last active
December 17, 2015 02:09
-
-
Save oinak/5534016 to your computer and use it in GitHub Desktop.
Curso de introducción a Ruby on Rails - Ej1
This file contains 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
#!/usr/bin/env ruby | |
class MegaGreeter | |
end | |
if __FILE__ == $0 | |
mg = MegaGreeter.new | |
mg.say_hi | |
mg.say_bye | |
# Change name to be "Worf" | |
mg.names = "Worf" | |
mg.say_hi | |
mg.say_bye | |
# Change the name to an array of names | |
mg.names = ["Riker", "Diana", "Geordi", "Wesley", "Data"] | |
mg.say_hi | |
mg.say_bye | |
# Change to nil | |
mg.names = nil | |
mg.say_hi | |
mg.say_bye | |
end | |
# Expected output: | |
# | |
# Hello Crew! | |
# Goodbye Crew. Come back soon! | |
# | |
# Hello Worf! | |
# Goodbye Worf. Come back soon! | |
# | |
# Hello Riker! | |
# Hello Diana! | |
# Hello Geordi! | |
# Hello Wesley! | |
# Hello Data! | |
# Goodbye Riker, Diana, Geordi, Wesley, Data. Come back soon! | |
# | |
# Hello Crew! | |
# Goodbye Crew. Come back soon! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment