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
We can now pattern match the Java Object as if it was any other map.
match.perf=> (matchm [(java.util.Date.20101011230)]
[{:year2009:month a}] a
[{:year (2010 | 2011) :month b}] b
:else:wrong)
10
Matching Java Beans
clojure.core/bean makes pattern matching Java Beans incredibly easy.
(extend-type java.awt.Color
IMatchLookup
(val-at [this k not-found]
(get (bean this) k not-found)))
match.core=> (match [java.awt.Color/black]
[{:red red :green green :blue blue}] [red green blue]
:else:error)
[000]
match.core=> (match [java.awt.Color/blue]
[{:red red :green green :blue blue}] [red green blue]
:else:error)
[00255]