Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dog
- attr_accessor :animal_type
- %w(cats dogs rabbits pigs cows).each do |t|
- define_method "has_#{t}" do |number|
- @animal_type = t
- puts number
- end
- end
- end
- d = Dog.new
- d.has_dogs 10
- puts d.animal_type
- p d.methods.sort
Add Comment
Please, Sign In to add comment