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' as an argument. While playing
with type hinting, I discovered things that I don't understand:
(defn f [#^Double x] (+ x 2)) => #'user/f
(f 3) => 5
(f nil) => java.lang.NullPointerException (NO_SOURCE_FILE:0)
; why NPE?
(f 2/3) => 8/3
; why not an error that argument isn't java.lang.Double?
(f "a") => java.lang.ClassCastException: java.lang.String cannot be
cast to java.lang.Number (NO_SOURCE_FILE:0)
; wants java.lang.Number, but I was hinting for java.lang.Double
Thank you, Frantisek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---