Replies: 2 comments 2 replies
-
Hey, thanks for the suggestion. I’d like to avoid monkey-patching If you want to use a patch in your own project, I believe this should work: class Object
def |(other)
Literal::Types::UnionType.new(self, other)
end
end
class Literal::Types::UnionType
def |(other)
@types << other
self
end
end |
Beta Was this translation helpful? Give feedback.
0 replies
-
I was thinking of a refinement that defines the method on Class along these lines: module UnionPipe
refine Class do
def |(other)
Literal::Types::UnionType.new(self, other)
end
end
end I’m going to play around with it though, thanks for the feedback! |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice to be able to do
I realize this would require monkey-patching or refinements to be used with built-in types, but, is a neat feature in Crystal that I think would be a good fit here.
Beta Was this translation helpful? Give feedback.
All reactions