You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there are other keys in the hash, you can use two separate schemas:
BAZ_FU=RSchema.define_hash{{'other_key'=>_Integer,'fu'=>_String,}}BAZ_FOO=RSchema.definedo# this is new, currently undocumented syntax that might changeHash_based_on(BAZ_FU,{'fu'=>nil,# removes 'fu' element'foo'=>_String,#adds new 'foo' element})endBAZ=RSchema.define{either(BAZ_FU,BAZ_FOO)}
Trying to building this into the hash schema raises a few questions. What if there are 3 exclusive keys instead of 2? What if a hash should have either the single key "name", or both of the keys "first_name" and "last_name"? I'd like to come up with a design that addresses these questions. I'll need some time to think about it.
I'd like to be able to define keys within a hash that are mutually exclusive (i.e., only one of them should exist).
Maybe it could look like something like:
The text was updated successfully, but these errors were encountered: