Ad
Code
Diff
  • class Person
      attr_accessor :name
    
      def initialize(name)
        self.name = name
      end
    end
    
    def change_name(new_name, thing)
      thing.name = new_name if thing.respond_to?(:name=)
    end
    
    
    • class Person
    • attr_accessor :name
    • def initialize(name)
    • @name = name
    • self.name = name
    • end
    • end
    • def change_name(new_name, thing)
    • if thing.respond_to?(:name=)
    • # do something
    • thing.name = new_name
    • else
    • nil
    • end
    • thing.name = new_name if thing.respond_to?(:name=)
    • end