From: Simon Strandgaard Date: 2004-04-13T06:49:17+09:00 Subject: Re: proposal - zip to do padding On Tue, 13 Apr 2004 01:01:40 +0900, Dan Doel wrote: > How do you propose to distinguish between normal arguments > to #zip and padding arguments to it? That is, when I call: > > [a, b, c].zip([1, 2, 3], [4, 5, 6]) > If it includes Enumerable, then its a normal argument. That would be: Array, String, .. If it doesn't its a padding argument. That would be: NilClass, Fixnum, .. > How do you know which of the following the output should be: > > [ [a, 1, 4], [b, 2, 5], [c, 3, 6] ] In your case, you have supplied 2 arrays to zip [a, b, c].zip([1, 2, 3], [4, 5, 6]) so you will get above output.. nothing changed here. However if you had chosen a value which didn't were compatible with Enumerable.. then it could be [a, b, c].zip([1, 2, 3], 4) #=> [ [a, 1, 4], [b, 2, 4], [c, 3, 4] ] > > I don't think you can work that out. You could pad with any value, but you > have to standardize it, because I don't see how you can reliably distinguish > between values-to-pad-with and values-to-zip-with. nil just makes the most > sense for a standard padding value. The reason it places your arguments > only in the first cell and pads with nil is that it thinks you're zipping with > two one-element arrays (string.to_a => [string]). Yes, true.. I forgot to mention how to distinguish between normal and padding. If the instance includes the Enumerable module, then normal. otherwise its a padding argument. Is it more clear now ? BTW: How can I make it more clear? -- Simon Strandgaard