简体   繁体   中英

Clojurescript - map from list of subvecs

I'm trying to create a map from a list of 2-element Subvec s.

This works fine in Clojure:

(into {} (list (subvec [1 2 3] 1)))
>> {2 3}

But fails in ClojureScript, with the following error:

No protocol method IMapEntry.-key defined for type number: 2

Replacing (subvec [1 2 3] 1) with [2 3] makes it work in both languages.

I'm new to ClojureScript, and can't find where this behaviour is documented. Is this a bug? And how would you suggest going around it efficiently?

Thanks!

I think it's an omission. Subvectors should be indistinguishable from ordinary vectors, and therefore Subvec should have an implementation of IMapEntry added to it, like the one in PersistentVector .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM