Using interop constructor in map function(Clojure)

后端 未结 2 885
南方客
南方客 2020-12-19 23:09

I am getting this complaint when passing Integer constructor to map function :

=> (map Integer. [\"1\" \"2\" \"3\"])
CompilerException java.lang.ClassNotF         


        
2条回答
  •  臣服心动
    2020-12-19 23:57

    map takes in a function and interop uses a special forms like new . and .. It is fairly easy to wrap these with anonymous function literals

    for example

    (map #(Integer. %) ["1" "2" "3"])
    

    produces the desired result.

提交回复
热议问题