If an object does not have a property and I am accessing the property, we get a MissingPropertyException. Can I do something similar to safe null (?.) to guard against missing properties so it doesn’t throw an exception?
If an object does not have a property and I am accessing the property,
Share
One option would be:
Which would return null if the object doesn’t have the property…
Another would be to add
propertyMissingto your class like so:This means that any missing properties would just result in null.