We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The def ===(o) = inside RespondTo (works if you switch it over to an ended method)
def ===(o) =
RespondTo
end
seeing_is_believing -ge ' module Types 2.times do using Types private def to_type(o) = (Symbol === o ? RespondTo.new(o) : o) def |(type) = Or.new(to_type(self), to_type(type)) refine(Module) { include Types } refine(Symbol) { include Types } end RespondTo = Struct.new(:name) { def ===(o) = o.respond_to?(name) def inspect() = ".respond_to?(#{name.inspect})" }.include(Types) Or = Struct.new(:left, :right) { def ===(o) left === o || right === o end def inspect() = "(#{left.inspect} | #{right.inspect})" }.include(Types) end using Types Integer | String | (:to_int | :to_str) # => ' -x
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The
def ===(o) =
insideRespondTo
(works if you switch it over to anend
ed method)The text was updated successfully, but these errors were encountered: