Skip to content

Instantly share code, notes, and snippets.

@enebo
Created February 19, 2018 18:47
Show Gist options
  • Save enebo/1266a5c2f6d09c2f38b83a83f758ac20 to your computer and use it in GitHub Desktop.
Save enebo/1266a5c2f6d09c2f38b83a83f758ac20 to your computer and use it in GitHub Desktop.
@JRubyMethod
public IRubyObject delete_prefix(ThreadContext context, IRubyObject arg) {
RubyString prefix = arg.convertToString();
if (!this.start_with_p(context, prefix).isTrue()) return this;
RubyString result = (RubyString) substr19(context.runtime, prefix.strLength(), this.strLength() - prefix.strLength());
return result.isEmpty() ? this : result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment