Apparently a list can be destructured as a map, but a vector cannot.

The "& args" syntax returns the result as a list, not a vector.

- James


On 27 August 2014 19:20, John Gabriele <jmg3...@gmail.com> wrote:

> Why is it that although this works:
>
> ~~~clojure
> (defn foo [& args] (let [{:keys [a b]} args] (str a \~ b)))
> ;;=> #'some-app.core/foo
> (foo :a 1 :b 2)
> ;;=> "1~2"
> ~~~
>
> this does not:
>
> ~~~clojure
> (let [{:keys [a b]} [:a 1 :b 2 :c 3]] (str a \~ b))
> ;;=> "~"
> ~~~
>
> ?
>
> And even stranger, *this* *does* work:
>
> ~~~clojure
> ;; Changed vector to a list.
> (let [{:keys [a b]} '(:a 1 :b 2 :c 3)] (str a \~ b))
> ;;=> "1~2"
> ~~~
>
> ?
>
> Incidentally, I see that the following `let` also does indeed work:
>
> ~~~clojure
> (let [ [& {:keys [a b]}] [:a 1 :b 2 :c 3] ] (str a \~ b))
> ;;=> "1~2"
> ~~~
>
> Thanks!
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to