From: Kaye Ng Date: 2011-03-07T20:39:32+09:00 Subject: basic programming question, help please class Square def initialize if defined?(@@number_of_squares) @@number_of_squares = @@number_of_squares + 1 else @@number_of_squares = 1 end end def self.count @@number_of_squares end end a = Square.new #would return 1 b = Square.new #would return 2 puts Square.count #2 would be printed on the screen -------------------------------------------------------------------- My question is: why is the "self" necessary in "def self.count". I don't understand the logic behind it. (I know that I can also type "def Square.count" instead of "def self.count") Thanks guys! -- Posted via http://www.ruby-forum.com/.