Skip to content

Instantly share code, notes, and snippets.

@k-tsj
Created December 28, 2013 10:02
Show Gist options
  • Save k-tsj/8157928 to your computer and use it in GitHub Desktop.
Save k-tsj/8157928 to your computer and use it in GitHub Desktop.
Object#assert_pattern
require 'pattern-match'
class Object
def assert_pattern(pattern)
match(self) do
with(Kernel.eval(pattern, Kernel.binding)) { self }
end
end
end
[0].assert_pattern('_[Integer]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment