What happens when I pass arguments to a Clojure symbol?

♀尐吖头ヾ 提交于 2019-12-19 13:06:52

问题


If I do this:

('a 'b 'c)

I get this:

c

Why?


回答1:


The link Hauleth posted is a good overview to symbols but the answer to your question is that calling a symbol as a function is equivalent to looking that symbol up in the first argument.

('a 'b)

is equivalent to

(get 'b 'a)

The documentation for get shows that you can pass an optional third argument as the default. In your example 'c is treated as the default and returned since 'b is not a map and 'a can't be found.



来源:https://stackoverflow.com/questions/8219305/what-happens-when-i-pass-arguments-to-a-clojure-symbol

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