-
Notifications
You must be signed in to change notification settings - Fork 166
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
Accessing map via primitive does not work #196
Comments
I see that the |
You're exactly right, all literal numbers in Pebble are treated as Longs. I suspect it also doesn't work for The only solution I can think of at the moment is brute force; cast the Long into every known java primitive type and attempt to look up a value in the map with that type. This is completely insane so I'm going to have to continue to think about it and I'm open to any suggestions. |
Well, we may not be able to determine the type of the map itself at runtime, but we can check the type of its keys. Perhaps the check could work like:
Little test:
Outputs:
For reference,
|
Just commited a fix for this |
Nice work! |
Accessing a
java.util.Map<Integer, Integer>
value by primitive value (int) will not return a value.Expected:
{{map[1]}}
should workThe text was updated successfully, but these errors were encountered: