Hacker News new | past | comments | ask | show | jobs | submit login

> The inconsistency here

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.




> Where is the inconsistency?

Between what happens when the start index is greater than the length of the input, and what happens when the end index is greater than the length of the input. If the end index is greater than the length of the input, it returns a string (as long as the start index is not greater than the length of the input). But if the start index is greater than the length of the input, it does not return a string: it returns null, which is not a string.

My suggestion is that the behavior would have made more sense if it either returned a string in both cases (i.e., if it returned a string even if the start index is greater than the length of the input), or returned null in both cases (i.e., if it returned null whenever the end index is greater than the length of the input).


> Between what happens when the start index is greater than the length of the input, and what happens when the end index is greater than the length of the input.

Again, what makes that an inconsistency and not just a different language?

> My suggestion is that the behavior would have made more sense

On the basis of the start and end indices being equivalent. But are they? What attributes of the language should see us consider them to be?


If you see no reason to think that the two indices ought to have been equivalent, then there is no inconsistency that you might care about.

> What attributes of the language should see us consider them to be?

None.


Maybe they are equivalent, but looking at what other languages do is irrelevant in determining that. If there is nothing else in Ruby to suggest that they are equivalent, then perhaps they are not?

I'm not sure where "care" enters into the picture. It's a computer language. For what reason would emotions be assigned to it?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: