Skip to content

Convenience methods on ArrayLiteral #16114

@straight-shoota

Description

@straight-shoota

Enumerable & co. have several convenience methods which make it a joy to work with. For example #max and #max_of (and the #min equivalents). These are really trivial to implement, but it's so nice to have them because they tell clearly what's happening.

In the macro language we're missing many of those methods on ArrayLiteral. It would be nice to have them there as well.
The workarounds you have to employ currently are quite ugly compared to the beauty of Crystal.

Example: #15927 (comment)

Now we certainly should not mirror the entire stdlib collection API in macro land. The macro language is intentionally limited because it has fewer use cases.
But some more convenience features would be very helpful. Finding the maximum or minimum value seems a very reasonable use case for macros, for example.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions