Skip to content

String#start_with? inconsistent with other Ruby implementations #2434

Description

@tobiashm

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?('')"
false
true
true

$ rvm jruby-head,ruby,rbx do ruby -e "p ''.end_with?('')"
true
true
true

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions