swannodette / mori

ClojureScript's persistent data structures and supporting API from the comfort of vanilla JavaScript

Home Page:http://swannodette.github.io/mori

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nth does not coerce

maxhoffmann opened this issue · comments

In the docs for nth it says:

For collections which are not sequential like sets and hash-map, the collection will be coerced into a sequence first.

When I tested nth it did not coerce though:

m.nth(m.set(['test']), 0)
m.nth(m.hashMap("name", "john"), 0)
// Error: nth not supported on this type

Manually converting the set to a sequence works:

m.nth(m.seq(m.set(['test'])), 0)
// 'test'
m.nth(m.seq(m.hashMap("name", "john")), 0)
// ["name" "john"]

Either the documentation is wrong or this is a bug. Or I am misunderstanding something as I just started playing around with mori. :)


tested in node 0.12 repl

I think documentation is wrong here. In ClojureScript nth doesn't coerce, and I don't see any code in mori that does the coercion.