Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upShould String/Array.slice accept 0 as an end argument #699
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Aug 24, 2016
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Aug 24, 2016
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
lukewestby
added
the
request
label
Aug 24, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andreaazzini
Aug 30, 2016
The slice functions behave exactly like their Javascript counterparts. IMHO, it wouldn't be right to make the Elm slice work differently. You can (and probably should) use the String.right function in this specific case.
> String.right 2 "Hello"
"lo" : StringHowever, the right function is not available in the Array module. Maybe we should discuss how to avoid this specific asymmetry.
andreaazzini
commented
Aug 30, 2016
|
The > String.right 2 "Hello"
"lo" : StringHowever, the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Sep 22, 2016
Member
Added to #322 that tracks all these ideas in one place. That way we can try to make more coherent API choices so things match across all core libraries.
|
Added to #322 that tracks all these ideas in one place. That way we can try to make more coherent API choices so things match across all core libraries. |
dannyob commentedAug 24, 2016
It seems very weird that you can easily slice from the start of a String or Array, but not to its end:
I think this is a side effect of Elm borrowing from Python -- Python slice indices can be negative, but they can also be None, which indicates either the start or the end of the list, depending on where they are used.
Conceivably we could use 0 as an end argument for this function, just as 0 as a start argument means "before the start." But it's all feeling a bit like null values here...
It feels like @sindikat might have some thoughts on this...