Moritz Lenz wrote: > From S29: > > : =item end > : > : our Any method end (@array: ) is export > : > : Returns the final subscript of the first dimension; for a one-dimensional > : array this simply the index of the final element. For fixed dimensions > : this is the declared maximum subscript. For non-fixed dimensions > (undeclared > : or explicitly declared with C<*>), the actual last element is used. > > > The last sentence seems to suggest that not the index of the last > element is returned, but the element itself. (Which I think is pretty weird) > > > And S02: > > : The C<$#foo> notation is dead. Use C<@foo.end> or C<@foo[*-1]> instead. > : (Or C<@foo.shape[$dimension]> for multidimensional arrays.) > > That doesn't clean it up totally either. > > So what should <a b c>.end return? 2 or 'c'? > (Currently pugs and elf return 2, rakudo 'c').
@foo[*-1] would return 'c'. @foo[*-1]:k would return 2. So the question is whether @foo.end returns @foo[*-1] or @foo[*-1]:k. You might also allow 'end' to take an adverb the way that 'postfix:' does, allowing you to explicitly choose what you want returned; but that still doesn't answer the question of what to return by default. -- Jonathan "Dataweaver" Lang