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

Support short blocks in #[] operator call's macro interpolation #14523

Conversation

HertzDevil
Copy link
Contributor

Before:

foo.[](&.bar)
foo.[]?(x: 1, &.bar)
foo.[]=(2, 3, y: 4, &.bar)

After:

foo[&.bar]
foo[x: 1, &.bar]?
foo[2, y: 4, &.bar] = 3

@ysbaddaden
Copy link
Contributor

A part of me thinks this is lovely, but the part is afraid of reading any code doing that (either the before or after versions). I have zero idea what they do.

@straight-shoota
Copy link
Member

The bracket syntax is already supported. This PR is just filling in support for short blocks. It might not be super useful, but it's solid. So there's not reason not to do this.

The assignment operator variant especially seems very weird, I agree on that 😆

@straight-shoota straight-shoota added this to the 1.13.0 milestone Apr 22, 2024
@straight-shoota straight-shoota merged commit 6a38569 into crystal-lang:master Apr 23, 2024
59 of 60 checks passed
@HertzDevil HertzDevil deleted the feature/index-operator-to_s-short-block branch April 23, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants