Allow string-to-array conversion in _.toArray() #276

Closed
pcorcoran opened this Issue Aug 15, 2011 · 3 comments

Comments

Projects
None yet
3 participants
@pcorcoran

_.toArray('abc') today throws a TypeError. It would great if it instead returned ['a','b','c']. A simple str.split('') would do.

(I understand the line in the sand regarding string functions. But treating strings as collections is a nice-n-functional thing to allow.)

Thanks!

@jashkenas

This comment has been minimized.

Show comment
Hide comment
@jashkenas

jashkenas Aug 16, 2011

Owner

Nope, sorry. It sounds like you've already read all the tickets discussing supporting strings as arrays of characters, so no need to rehash here.

TypeError is definitely what you want in this case.

Owner

jashkenas commented Aug 16, 2011

Nope, sorry. It sounds like you've already read all the tickets discussing supporting strings as arrays of characters, so no need to rehash here.

TypeError is definitely what you want in this case.

@jashkenas jashkenas closed this Aug 16, 2011

@benekastah

This comment has been minimized.

Show comment
Hide comment
@benekastah

benekastah Jan 4, 2012

@jashkenas Could you please link to any issues that cover why underscore doesn't support strings as arrays of characters? Thanks.

@jashkenas Could you please link to any issues that cover why underscore doesn't support strings as arrays of characters? Thanks.

@jashkenas

This comment has been minimized.

Show comment
Hide comment
@jashkenas

jashkenas Jan 4, 2012

Owner

I don't know them off the top of my head, but Github Issues search should be able to help you.

Underscore doesn't support strings as arrays of characters because strings aren't arrays of characters in JavaScript.

Owner

jashkenas commented Jan 4, 2012

I don't know them off the top of my head, but Github Issues search should be able to help you.

Underscore doesn't support strings as arrays of characters because strings aren't arrays of characters in JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment