Hi
I am just testing clojure :pre condition. But look like using keyword?, it
is not working in clojure 1.5.1.
(defn check-keyword [v] {:pre [keyword? v]} v)
(defn check-nil [v] {:pre [nil? v]} v)
(check-keyword “sdf”) ;Not throwing exception here
(check-nil nil) ;Throwing exception
Br,
Hi Mamun,
This is the correct syntax (you're missing some parens).
(defn check-keyword [v] {:pre [(keyword? v)]} v)
Thanks,
Ambrose
On Thu, Feb 13, 2014 at 6:47 PM, Mamun mamuni...@gmail.com wrote:
Hi
I am just testing clojure :pre condition. But look like using keyword?, it
is not
HI Ambrose,
Thanks for your reply. But why this one is working?
(defn check-nil [v]
{:pre [nil? v]}
v)
Br,
Mamun
On Thursday, February 13, 2014 11:51:31 AM UTC+1, Ambrose Bonnaire-Sergeant
wrote:
Hi Mamun,
This is the correct syntax (you're missing some parens).
It doesn't work, in your OP it incorrectly throws an exception when you
pass it nil.
:pre just takes a sequence of expressions which are executed like `do`, and
throws an exception if any expression returns a false value.
Thanks,
Ambrose
On Thu, Feb 13, 2014 at 7:53 PM, Mamun