nth does not coerce
maxhoffmann opened this issue · comments
Max Hoffmann commented
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
Sergey Smyshlyaev commented
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.