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 <mamuni...@gmail.com> wrote: > 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). >> >> (defn check-keyword [v] {:pre [(keyword? v)]} v) >> >> Thanks, >> Ambrose >> >> >> On Thu, Feb 13, 2014 at 6:47 PM, Mamun <mamu...@gmail.com> wrote: >> >>> 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, >>> >>> Mamun >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To post to this group, send email to clo...@googlegroups.com >>> >>> Note that posts from new members are moderated - please be patient with >>> your first post. >>> To unsubscribe from this group, send email to >>> clojure+u...@googlegroups.com >>> >>> For more options, visit this group at >>> http://groups.google.com/group/clojure?hl=en >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to clojure+u...@googlegroups.com. >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.