Skip to content

Consider returning the default value instead of nil, when sending :first or :last to an empty collection #8

@stormwatch

Description

@stormwatch

It is my understanding that all these sorted collections rely ultimately on the behaviour of sorted array, which right now is returning nil always for an empty collection, regardless of the default configured value when the collection is instantiated. Besides of returning the default value, also consider adding first_if_empty(&block_closure) and :last_if_empty(&block_closure) and/or allowing to optionally pass an a block to :first and :last in the same manner as :fetch does.

By the way, thanks for publicly sharing this collection of collections in the first place. All of these should be included in the standard library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions