Last active
August 29, 2015 14:07
-
-
Save jcarouth/5254125eb0e75244339f to your computer and use it in GitHub Desktop.
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
class Character | |
attr_accessor :name | |
def initialize(attributes = {}) | |
attributes.each do |attr, value| | |
setter = "#{attr}=" | |
send(setter, value) if self.respond_to?(setter) | |
end | |
end | |
end | |
characters = %w(Joe Bob Guido).inject([]) do |arr, name| | |
arr << Character.new(:name => name) | |
end | |
puts characters.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment