Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
String#start_with? inconsistent with other Ruby implementations #2434
Both MRI and Rubinius returns
I would suggest that JRuby should change its behavior for
$ rvm jruby-head,ruby,rbx do ruby -e "p ''.start_with?('')" false true true $ rvm jruby-head,ruby,rbx do ruby -e "p ''.end_with?('')" true true true
This appears to be a bug in ByteList. The logic for startsWith includes this line:
if (realSize == 0 || this.realSize < other.realSize + toffset) return false;
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.