Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:51:45+00:00 2026-05-26T16:51:45+00:00

Ruby on Rails has the method String#starts_with? , which is implemented in Ruby with

  • 0

Ruby on Rails has the method String#starts_with?, which is implemented in Ruby with

# File lib/active_support/core_ext/string/starts_ends_with.rb, line 22
def starts_with?(prefix)
  prefix = prefix.to_s
  self[0, prefix.length] == prefix
end

whereas Ruby, since version 1.8.7, has the method String#start_with?, which is implemented in C

static VALUE
rb_str_start_with(int argc, VALUE *argv, VALUE str)
{
    int i;

    for (i=0; i<argc; i++) {
        VALUE tmp = rb_check_string_type(argv[i]);
        if (NIL_P(tmp)) continue;
        rb_enc_check(str, tmp);
        if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
        if (memcmp(RSTRING_PTR(str), RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
            return Qtrue;
    }
    return Qfalse;
}

Why don’t they just have an alias linking from starts_with? to start_with??

Do they wish to maintain compatibility with Ruby 1.8.6, or are they worried that start_with? may have different behavior to starts_with?, or have they not seen the need to update the code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:51:45+00:00Added an answer on May 26, 2026 at 4:51 pm

    From your code, it looks like you have a really old version of Rails at hand (<= 2.3.5). As this version supported older Ruby versions, which didn’t yet had start_with? they implemented it by hand.

    However if you look above in the file, you see that they used the ruby built-in method if it is available. In newer Rails versions where the Ruby 1.8.6 support was dropped, these magic bits were removed and ActiveSupport now provides unconditional aliases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site built in Ruby On Rails which has many ads in
In Ruby on Rails, each model entity has a validate_on_ something hook method, that
Ruby on Rails has magic timestamping fields that are automatically updated when a record
Ruby on Rails has a lot of ways to generate JavaScript. Particularly when it
Ruby on Rails has become a new competitive face in the server programming industry,
Ruby on Rails has a screencast presentation they use to promote their framework that
After our Ruby on Rails application has run for a while, it starts throwing
Has anyone used Ruby/Rails with a Sales Logix database?
Has accept_nested_attributes_for already works with Rails 2.3.5 and Ruby 1.9.1???? I keep getting this
(Here's my requisite line about being new to ruby/rails and programming in general; first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.