What happens when I pass arguments to a Clojure sy

2019-02-21 09:49发布

If I do this:

('a 'b 'c)

I get this:

c

Why?

1条回答
混吃等死
2楼-- · 2019-02-21 10:39

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.

查看更多
登录 后发表回答