You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both MRI and Rubinius returns true when testing if an empty string starts with an empty string. But JRuby returns false. But when testing if the empty string ends with an empty string, they all return true.
I would suggest that JRuby should change its behavior for String#start_with?.
I've looked in the source code, but wasn't able to figure out where and how this change should be implemented, partly because it seems that the call is forwarded to some Java classes.
$ rvm jruby-head,ruby,rbx do ruby -e "p ''.start_with?('')"falsetruetrue
$ rvm jruby-head,ruby,rbx do ruby -e "p ''.end_with?('')"truetruetrue
The text was updated successfully, but these errors were encountered:
This also happens on 1.7 as well. Marked for 1.7.19 since this should be simple to fix (no doubt just looking at end_with? will give the snippet missing from begin_with?). I even marked it beginner if someone wants to try and submit their first PR.
Whether we should change this behavior is debateable...on the one hand, the string doesn't start with anything. On the other, it starts with nothing and the incoming string is nothing.
In any case, we need to fix at Ruby level, and it appears that end_with also uses this logic, so there must be a short-circuit somewhere.
Both MRI and Rubinius returns
true
when testing if an empty string starts with an empty string. But JRuby returnsfalse
. But when testing if the empty string ends with an empty string, they all returntrue
.I would suggest that JRuby should change its behavior for
String#start_with?
.I've looked in the source code, but wasn't able to figure out where and how this change should be implemented, partly because it seems that the call is forwarded to some Java classes.
The text was updated successfully, but these errors were encountered: