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
In spec/spec_helper.rb maybe add $VERBOSE = nil so you aren't spammed with warnings
In general, you can make the syntax a lot terser like this:
- value =- case Dio.attribute(alice)- in { name: /^A/, age: 30..50 }- true- else- false- end-+ value = (Dio.attribute(alice) in { name: /^A/, age: 30..50 })
Ultimately this is going to hit an issue where, wanting to match things with #=== are going to create problems. I looked through the C code, and there isn't a way to interject between them. Eg consider p((Dio.dynamic(1) in { succ: { succ: { succ: Integer } } })), for that Integer to match, it requires that Dio[3].deconstruct_keys([:succ]) returns {succ: 4}, where 4 is an integer, and not a Dio::Forwarders::BaseForwarder, because it will not delegate the class lookup, thus it will not consider the wrapped integer to be an integer:
And you can't extend such objects b/c you can't extend integers
And you can't refine them, b/c the Ruby C code doing the pattern matching won't see the refinement
So you can only actually implement it with a monkey patch:
The text was updated successfully, but these errors were encountered:
spec/spec_helper.rb
maybe add$VERBOSE = nil
so you aren't spammed with warnings#===
are going to create problems. I looked through the C code, and there isn't a way to interject between them. Eg considerp((Dio.dynamic(1) in { succ: { succ: { succ: Integer } } }))
, for thatInteger
to match, it requires thatDio[3].deconstruct_keys([:succ])
returns{succ: 4}
, where4
is an integer, and not aDio::Forwarders::BaseForwarder
, because it will not delegate the class lookup, thus it will not consider the wrapped integer to be an integer:The text was updated successfully, but these errors were encountered: