From: Eric Mahurin Date: 2005-06-01T22:16:55+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 ? If you are simply making a sub-class of Array, no. > if yes how? I think a valid reason for restricting what goes into the array would be efficiency - runtime or memory. In the case of Fixnum, you only lose 1-bit - Fixnum is a 31-bit int using 32 bits of space. If you want an array of homogenous numbers, narray allows you to store various sizes of ints, floats, and complex numbers. I wouldn't mind having something that made a homogenous array of whatever - mainly for memory efficiency. > if not why? It may be useful to put things that look like and act like an integer in this array. If you put something that doesn't act like an integer in here, you'll find the problem when you take it out of the array and try to use it like an integer. And if you don't use it like an integer I see no need for any restriction. __________________________________ Discover Yahoo! Find restaurants, movies, travel and more fun for the weekend. Check it out! http://discover.yahoo.com/weekend.html