Search code examples
clojureclojurescript

Clojurescript - map from list of subvecs


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

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!


Solution

  • 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.