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

  • Home
  • SEARCH
  • 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 850969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:21:10+00:00 2026-05-15T07:21:10+00:00

Is this a ruby bug? target_url_to_edit = target_url if target_url_to_edit.include?(http://) target_url_to_edit[http://] = end logger.debug

  • 0

Is this a ruby bug?

target_url_to_edit = target_url

if target_url_to_edit.include?("http://")
  target_url_to_edit["http://"] = ""
end

logger.debug "target url is now #{target_url}"

This returns target_url without http://

  • 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-15T07:21:11+00:00Added an answer on May 15, 2026 at 7:21 am

    You need to duplicate the in-memory object because variable names are just references to in-memory objects:

    target_url_to_edit = target_url.dup
    

    Now target_url_to_edit gets assigned a new copy of the original object.

    For your case this code probably does the same in just one line (no dup, no if):

    target_url_to_edit = target_url.sub(%r{^http://}, "")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

having sorted this error - Ruby mysql2 Error I now am recieving this error
This bug may be lurking since the beginning of ruby-mode , but I noticed
Does Ruby have a bug in its rounding? Why does it behave like this:
Originally this bug was posted here: https://rails.lighthouseapp.com/projects/8994/tickets/5713-ruby-19-ku-incompatible-with-mem_cache_store And now, as we've run into the
If I execute this ruby code: def foo 100 end p defined?(foo), foo if
I get this RVM error when I install rubygems. /Users/yannick/.rvm/gems/ruby-1.9.2-p290/gems/yard-0.7.3/lib/yard.rb:38: [BUG] Bus Error ruby
I'm looking for a workaround to this Published Twitter API bug: http://code.google.com/p/twitter-api/issues/detail?id=214 When you
The bug is many months old, here: http://www.ruby-forum.com/topic/1094002 Two links in that which show
UPDATE 2 This is a known bug/feature with the way Ruby 1.9.2 loads files.
I am newbie in Ruby. I installed by following this tutorial: http://udooz.net/blog/2011/02/facebook-app-using-rails-koala/ Now, when

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.