What happens when I pass arguments to a Clojure symbol?

后端 未结 1 877
悲&欢浪女
悲&欢浪女 2021-01-17 12:43

If I do this:

(\'a \'b \'c)

I get this:

c

Why?

相关标签:
1条回答
  • 2021-01-17 13:04

    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.

    0 讨论(0)
提交回复
热议问题