Markus Schirp wrote:
> class Example
>   def init(size)    # why u arent using initialize?
>     @arr = Array.new
>     @index = -1
>   end

Just to flesh out that comment.  Examine this class:

class Dog
  def init_method(age, weight)
    @age = age
    @weight = weight
  end

  def show
    puts @age, @weight
  end
end


d = Dog.new
d.init_method(2, 20)
d.show

--output:--
2
20


However, when you create an object, ruby *automatically* calls a method 
called initialize() in the object's class:

class Dog
  def initialize(age, weight)
    @age = age
    @weight = weight
  end

  def show
    puts @age, @weight
  end
end


d = Dog.new(2, 20)
d.show

--output:--
2
20


-- 
Posted via http://www.ruby-forum.com/.