Hello -- On Tue, 24 Jul 2001, Stephen White wrote: > On Tue, 24 Jul 2001, Will Conant wrote: > > > In Ruby, there's only one reasonable place to look for Array functions... > > in the Array class. > > There's one exception to this... methods that are split between classes > or convert between classes. > > Eg, "pack" is in Array and "unpack" is in String. Other examples, "grep" > in Enumerable, "join" in Array, "split" in String, etc. > > They're very useful, but they're still spread across classes rather than > being encapsulated. This isn't too painful while there's only a few main > classes, but the number of connections and one-way streets would grow > exponentially with more classes. But if (say) Array#join => aString is a problem, then what about Array.size => Fixnum? A rhetorical question, I guess :-) but my point is that, to me, it doesn't seem wrong for a method in a given class to return an object of another type. Otherwise all Array methods would have to return arrays, which would be pretty constrictive. On the other hand, methods in Enumerable that return Arrays might be viewed as kind of circular, since Array mixes in Enumerable.... I guess Array and Enumerable sort of bootstrap each other. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav