I understand why the first statement prints `true`...
# getting-started
e
I understand why the first statement prints
true
but not why the second one does. I'd only expect substrings of the alphabet to return
true
. What's going on?
k
It's checking whether the string would fall in the range using the default string comparator, which is alphabetical order. "apple" would indeed be after "a" and before "z" alphabetically
🫠 5
🙏🏾 1
🙏 2
More in-depth answer here https://stackoverflow.com/a/46764287
🙏 1
e
Very cool! I verified that the following expression is false:
Copy code
"zz" in "a".."z"
👍 1
v
apple doesn't fall in the range a..z
v
Why not? Obviously it does.
e
According to
compareTo()
it does.