From: Robert Klemme Date: 2005-06-01T18:15:23+09:00 Subject: Re: array of object insert polices dave wrote: > hy list, > > if i have a class as: > > class IntegerArrray < Array > end > > should i check if user inserts non Integer values ? What other reason would there be for IntegerArray other than making it a type safe array for integers? > if yes how? def ensure_int(obj) raise TypeError, "Not an int: #{obj.inspect}" unless Integer === obj end And call this whenever new elements enter the (<<, []= ...). > if not why? Duck typing. Code that relies on ints in there will soon discover if someone puts something non numeric in there. Kind regards robert