Skip to content

Instantly share code, notes, and snippets.

@oinak
Last active December 17, 2015 02:09
Show Gist options
  • Save oinak/5534016 to your computer and use it in GitHub Desktop.
Save oinak/5534016 to your computer and use it in GitHub Desktop.
Curso de introducción a Ruby on Rails - Ej1
#!/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