Mega Code Archive

 
Categories / Ruby / Class
 

Add method implementation for object instance

class Button   def pushed   end end buttonA = Button.new def buttonA.pushed   puts "BBB" end buttonB = Button.new def buttonB.pushed   puts "AAA" end Button.new.pushed # buttonA.pushed # BBB buttonB.pushed # AAA