allow to convert any object to matcher if it has === method
Product can have its fields named.
Matchers also support logical operations #& for and, #| for or, and #! for negation.
Let's define some types
Whenever you find yourself to pass around too many fragile Hash-Array structures e.g. for menus.
Lets define message-protocol for a cross-process communication.
It also works as expected when modules like Comparable are included.
Simple data structures like trees
# File doc/pattern_matching.in.rb, line 86 def color?(color) match color, on(Black | Grey.(-> v { v < 0.2 }), 'black-ish'), on(White | Grey.(-> v { v > 0.8 }), 'white-ish'), on(Grey.(-> v { v >= 0.2 }) & Grey.(-> v { v <= 0.8 }), 'grey-ish'), on(Pink, "that's not a color ;)") end
# File doc/null.in.rb, line 3 def deliver_email(email) true end
# File lib/algebrick/matchers/wrapper.rb, line 52 def to_m Wrapper.new(self) end