Clojure: returning a vector from an anonymous function

微笑、不失礼 提交于 2019-11-28 21:16:56

Your problem is that the simple syntax is trying to evaluate the vector as a function call.

You can insert an "identity" function to make it work, as this is just a simple function that will return the vector unchanged:

#(identity [(keyword %) (.getObject resultset %)])

You need to use vector function to do this:

#(vector (keyword %) (.getObject resultset %))

P.S. there are also functions for maps, sets, etc.

Yeah, Clojure should really support a #[...] construct, just for this case.

I would recommend the following as the best alternative:

#(vector (keyword %) (.getObject resultset %))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!