|
|
|
|
|
by LegionMammal978
689 days ago
|
|
Fine, it's 'accepted' in the basic sense that it doesn't throw an immediate error. But it also doesn't return any useful string, as Python would. So you'd need an extra step to feed its output into anything expecting a non-null string. The inconsistency here is that when you call "abc".slice(2, 10) and get "c", Ruby has implicitly truncated the range to return whatever characters are available, even though it can't go all the way to 10 because the string isn't long enough. But then when you call "abc".slice(4, 10), it doesn't just give you all available characters from index 4 (which would be an empty string), it gives you null instead. |
|
I don't see the inconsistency. slice on Array works the same way. Where is the inconsistency?
> (which would be an empty string)
What other aspect of Ruby would suggest that it is an empty string?
If what you are struggling to say is that different languages are different, then okay. "Japanese is unlike the English I know and therefore is inconsistent" would be a rather bizarre take, though.