-
Notifications
You must be signed in to change notification settings - Fork 10
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
Backreferences? #22
Comments
It'd try and do literal compare -> methodized compare. Back references don't currently work as Qo has no idea of that level of introspection. |
Now as to how to do that, it'd have to be an entirely different syntax. I could see something along the lines of adding a handler to Qo: Qo2 = Qo.with(back_reference: true, bidirectional_matching: true)
Qo2[:foo => :bar, :bar => :foo] === {foo:42, bar:42} # true |
How about something like... Qo[foo: Qo[:bar], bar: Q[:foo]] That would requiring modifying the hash matcher to notice that the value matcher is another Qo, and then apply it to the target object to get the value to be matched. It would be a small performance penalty, which I know you're against, but it makes the syntax cleaner. |
As soon as I posted that I thought of an another idea. Funny how that works. Taking a page from the Qo[foo: BR[:bar], bar: BR[:foo]] |
Thinking about this in the process of releasing 0.99, this seems a bit out of place for the current API. |
What's the Qo-ish way to affect something similar to backreferences?
For example, match a Hash where the value of the
:foo
key matches the value of the:bar
key.The text was updated successfully, but these errors were encountered: