Replies: 2 comments 6 replies
-
I don't think changing the names is a good idea now, as it would be a breaking change and probably add more confusion than resolving it. However, this is the rationale for the names:
Sorry for the inconvenience. |
Beta Was this translation helpful? Give feedback.
3 replies
-
still no get(key) function for default value? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Improvement
The library would be more usable if it offered
get(key, default=null)
interface.Why
A great feature of this library is bringing the power of Python/Javascript objects to C++.
Only it lacks
object.get(key, default=null)
interface, which is such an useful feature!Turns out that the functionality is actually there, but the choice of name "value" is not adequate. It takes a bit of research to find, actually I thought it was not there for a while and had to implement it myself.
It also happens that the semantics of "get" and "value" are swapped: each one means what the other says!
Since swapping "get()" with "value()" would break existing code, I hereby propose to make them work both ways:
get(key, default) == value(key, default)
value() == get()
Please describe the steps to reproduce the issue.
object.get(key, default)
???object.contains(key) ? object[key] : default
Beta Was this translation helpful? Give feedback.
All reactions