Clojurescript - map from subvecs list

I am 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 crashing 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]does the job in both languages.

I am new to ClojureScript and cannot find where this behavior is documented. This is mistake? And how would you suggest effectively circumventing it?

Thank!

+4
source share
1 answer

I think this is an omission. Subventors must be indistinguishable from ordinary vectors, so Subvec must have an IMapEntry implementation added to it, such as the one in PersistentVector .

+3
source

Source: https://habr.com/ru/post/1681829/


All Articles