30 Aug 2013

Clojure puzzler #2

Seven lines of Clojure, numbered for easy reference. From which lines do you get a reflection warning?

(set! *warn-on-reflection* true)                          ; 1
                                                          ; 2
(Thread. (fn [] (prn 1)) "foo")                           ; 3
(Thread. :x "foo")                                        ; 4
(Thread. (if true (fn [] (prn 1)) (fn [] (prn 2))) "foo") ; 5
(Thread. (if true (fn [] (prn 1)) :x) "foo")              ; 6
(Thread. (if true :y :x) "foo")                           ; 7

2 comments:

  1. I really found very interesting about these topic because robotics is a field that covers almost all the spheres of technology, whether it is Medical, Mechanical, Electronics, Computer Programming, Designing Techniques or any other technical skills based on respective applications.
    Duct inspection companies in India

    ReplyDelete