Beginning Ruby

Been reading a tutorial ruby book, and i’m not sure if this error is
caused by a typo in the book, or some logical error only the experienced
would know how to correct

/code//

class Square
def intialize
if defined?(@@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
b = Square.new
puts Square.count

///

Here’s the error:

///

ruby Square.rb
Square.rb:11:in count': uninitialized class variable @@number_of_squares in Square (NameError) from Square.rb:17 Exit code: 1 ruby Square.rb Square.rb:10: undefined local variable or methods’ for Square:Class
(NameError)
Exit code: 1
ruby Square.rb
Square.rb:11:in `count’: uninitialized class variable
@@number_of_squares in Square (NameError)
from Square.rb:17
Exit code: 1


The triple slashes(///) aren’t part of the code, just to make reader
friendly

Many thanks in advanced.

Just correct the typo.

def intialize

should be

def initialize

And it works. ; )

Lol thanks I can’t believe i didn’t notice that.