On Mar 22, 2:34 pm, Frantisek Sodomka wrote:
> (defn f [#^Double x] (+ x 2)) => #'user/f
> (f 3) => 5
> (f nil) => java.lang.NullPointerException (NO_SOURCE_FILE:0)
> ; why NPE?
nil is Java null. The Clojure "+" function eventually compiles to
Java "+", which throws an exception on null.
> (f
Hello Rich & everybody!
clojure.set/union currently accepts 'nil' as a valid argument:
(union nil) => nil
(union nil nil) => nil
(union nil #{1 2}) => #{1 2}
(union #{1 2} nil) => #{1 2}
(union #{} nil) => #{}
(union nil #{}) => nil ; not consistent
Possible solution would be to ban 'nil