#472 Add firstitem, lastitem methods to ordered collections.

v4.2.0
closed
Rick McGuire
Classes (154)
complete
5
2014-04-15
2012-07-06
Rick McGuire
No

The ordered collection classes have first and last methods that return the indexes of the first and last items, but if the collection is empty, these return .nil for the index, which cannot be used directly and must be tested for validity first. Since retrieving the first or last item is a common operation, firstItem and lastItem seem like natural additions for these classes.

Discussion

  • Jon Wolfers
    Jon Wolfers
    2012-08-16

    Not sure I get this, what would firstitem and lastItem return for an empty collection?

     
  • Rick McGuire
    Rick McGuire
    2012-08-25

    • status: open --> accepted
    • assigned_to: Rick McGuire
    • pending_work_items: --> code+doc+test
     
  • Rick McGuire
    Rick McGuire
    2012-08-25

    Jon, .nil, of course. These methods have been implemented for the List class for some time (I believe these methods were there in the original turned over from IBM). This will make the ordered collections more consistent in their method usage.

     
  • Rick McGuire
    Rick McGuire
    2014-04-15

    • status: pending --> closed
     


Anonymous


Cancel   Add attachments