2 ms·
Well it seems to work with 1.7. Try: (let [[[:a a] [:b b]] (vec {:a 1 :b 2})] (println a b)) But yeah, it's just
by harperlee 10y ago
Well it seems to work with 1.7. Try:
(let [[[:a a]
[:b b]] (vec {:a 1
:b 2})]
(println a b))
But yeah, it's just an old and ugly hack from when I knew no better. It should look like your version.
- dghf 10y agoYou're right, it works under 1.7. But not under 1.8: I get an "Unsupported binding form" exception. A bit of digging suggests it was an unwanted side effect of allowing destructuring of name-spaced keywords in maps, introduced in 1.5: > CLJ-1318 ("Support destructuring maps with namespaced keywords") introduced two potentially undesired behaviours: > [snip] > 2. Keywords were allowed in any binding key positions. Keywords are converted to symbols (retaining namespace) and treated according to the rules of symbols in the rest of the destructuring logic. From what I understand the idea was to allow keywords only in map destructuring, but again the change change was effected for any binding key. -- http://dev.clojure.org/jira/browse/CLJ-1778 http://dev.clojure.org/jira/browse/CLJ-1778 1.8 removed keyword-first destructuring forms for vectors.