-
Notifications
You must be signed in to change notification settings - Fork 14
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
truthiness of objects #34
Comments
So part of the problem is that JsonLogic is pretty crummy at handling inline objects, because it tries to use
But even if we push it into a variable, I bet empty objects are sort of inconsistent by implementation. Do you have an opinion what it should be? I think in both languages I maintain implementations for (JavaScript and PHP) objects are truthy, even empty objects. That seems the easiest to make consistent (you wouldn't have to wonder about whether an object with zero public attributes but some private attributes should behave, do methods count as properties in your language, etc etc) |
I have a client who's expecting existence to be truthy. (See linked issue.) The specific use case has a non-empty object, so I'm not sure about empty objects. Personally I have no preference, other than it should be defined. I just want to know what to implement. Non-empty objects being truthy and empty objects being falsy would align with how arrays are treated. |
@jwadhams do you have any more information on this? |
The table presented on the website doesn't list how to treat objects (empty or non-empty) in regard to truthiness. Is this defined somewhere else?
On your playground,
returns
true
, whilereturns nothing.
The text was updated successfully, but these errors were encountered: