Skip to content
Robin Munn edited this page Feb 23, 2014 · 4 revisions

A checkable has three parts: a left-hand side, an arrow, and a right-hand side. With the normal => arrow, the left-hand side and right-hand side are evaluated, then the results are compared using extended equality. Extended equality is by default =, but the type of the right (and sometimes the left) side can change that. By far the two most important cases are:

  • functions

    A function on the right-hand side is given the result of evaluating the left-hand side. If the result is any value that Clojure counts as true, the check succeeds.

  • regular expressions

    This checkable:

    (f) => #"foo+"

    ... means the same thing as this:

    (re-find #"foo+" (f)) => truthy

    (truthy is a checker that succeeds when given any value that Clojure counts as true.)

=> is not the only kind of arrow. Other arrows behave differently. The most important is =not=> or =deny=>. The check succeeds only if extended equality does not produce a truthy value.

(fact (nth-prime 100) =not=> even?)

See the checkable arrows for the other arrows.

Clone this wiki locally