From: jack jones Date: 2011-09-04T08:16:15+09:00 Subject: arrays(setters and getters) # whats wrong with that class Whatever attr_accessor :array @array def initialize @array = [] @array = ["apple", "banana", "peach"] end def array []= (i,value) # setter @array[i] = value end def array[] (i) #getter @array[i] end end shehio = Whatever.new puts shehio.inspect puts shehio.array puts shehio.array[0] puts shehio.array[1] puts shehio.array[2] shehio.array[0] = 1 shehio.array[0] = 2 shehio.array[0] = 3 puts shehio.array[0] puts shehio.array[1] puts shehio.array[2] -- Posted via http://www.ruby-forum.com/.