Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sort_by macro method #3947

Merged
merged 1 commit into from Jan 30, 2019

Conversation

Projects
None yet
5 participants
@jreinert
Copy link
Contributor

commented Jan 27, 2017

{{ ["abc", "a", "ab"].sort_by { |string| string.size } }}
@bcardiff
Copy link
Member

left a comment

A documentation placeholder should be added at https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/macros.cr#L543 .

I'm curious, which scenario forced you sort in macros?

@jreinert jreinert force-pushed the jreinert:sort_by_macro_method branch from 3fdd401 to c14033f Jan 27, 2017

@jreinert

This comment has been minimized.

Copy link
Contributor Author

commented Jan 27, 2017

@bcardiff done :) Sorry I forgot about that. I was writing a kind of model interface similar to json mapping and was building an initializer that would take arguments from the mapping named tuple. There i needed to sort the arguments by nilable so that args that are mandatory are leftmost.

There are other ways of doing it of course but i was confused that ArrayLiteral didn't have a sort_by method so i thought it would be nice to have.

Show resolved Hide resolved src/compiler/crystal/macros/methods.cr Outdated

@jreinert jreinert force-pushed the jreinert:sort_by_macro_method branch from c14033f to ae7b8da May 22, 2017

@straight-shoota

This comment has been minimized.

Copy link
Member

commented Jan 8, 2019

@jreinert Could you rebase on master?

@jreinert jreinert force-pushed the jreinert:sort_by_macro_method branch from ae7b8da to 63d7e5f Jan 14, 2019

@jreinert

This comment has been minimized.

Copy link
Contributor Author

commented Jan 14, 2019

@jreinert

This comment has been minimized.

Copy link
Contributor Author

commented Jan 28, 2019

@RX14

RX14 approved these changes Jan 30, 2019

@RX14 RX14 merged commit d58a06e into crystal-lang:master Jan 30, 2019

5 checks passed

ci/circleci: check_format Your tests passed on CircleCI!
Details
ci/circleci: test_darwin Your tests passed on CircleCI!
Details
ci/circleci: test_linux Your tests passed on CircleCI!
Details
ci/circleci: test_linux32 Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@RX14 RX14 added this to the 0.28.0 milestone Jan 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.