-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rename NamedTupleLiteral#[] to NamedTupleLiteral#[]? #5766
Comments
Actually, I just realized that {% nt = {a: 1}; puts nt[:non_existant] %} # => nil I think the documentation should be changed, or the method renamed to what it really is |
Documentation should be fixed, but it makes no sense to rename to |
Do we have |
@jhass is right: methods are nilable by default in macros, unlike runtime methods that raise by default and may have a nilable alternative. Close? |
Close. |
I have a macro-land array of
NamedTupleLiteral
, each representing a field of data to parse for a binary protocol (this is my usecase).Here is an example:
Now I need to get all the fields that needs to be saved:
This works (https://carc.in/#/r/3o3w).
But with
NamedTupleLiteral#[]?
, this could be rewritten as:Which feels way better, and simpler to understand.
It is currently missing, and I think it should be added! 😃
I can send a PR if you agree
The text was updated successfully, but these errors were encountered: