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 574727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:51:44+00:00 2026-05-13T13:51:44+00:00

I see a lot of this sort of this going on in Ruby: myString

  • 0

I see a lot of this sort of this going on in Ruby:

myString = "Hello " << "there!"

How is this different from doing

myString = "Hello " + "there!"
  • 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-13T13:51:44+00:00Added an answer on May 13, 2026 at 1:51 pm

    In Ruby, strings are mutable. That is, a string value can actually be changed, not just replaced with another object. x << y will actually add the string y to x, while x + y will create a new String and return that.

    This can be tested simply in the ruby interpreter:

    irb(main):001:0> x = "hello"
    => "hello"
    irb(main):002:0> x << "there"
    => "hellothere"
    irb(main):003:0> x
    => "hellothere"
    irb(main):004:0> x + "there"
    => "hellotherethere"
    irb(main):005:0> x
    => "hellothere"
    

    Notably, see that x + "there" returned “hellotherethere” but the value of x was unchanged. Be careful with mutable strings, they can come and bite you. Most other managed languages do not have mutable strings.

    Note also that many of the methods on String have both destructive and non-destructive versions: x.upcase will return a new string containing the upper-case version of x, while leaving x alone; x.upcase! will return the uppercased value -and- modify the object pointed to by x.

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

Sidebar

Related Questions

I see that there are A LOT of related questions on this one, and
I see a lot of this: 06-19 17:29:11.911: DEBUG/dalvikvm(10028): GC_FOR_MALLOC freed 729K, 54% free
In a lot of TDD tutorials I see code like this: public class MyClass
This code I am looking at has a lot of places where I see
Can someone explain ProxyFactoryBean in simple terms? I see this being quoted lot of
I see a lot of different point of views on internet concerning meta tags
I see a lot of debate going back and forth on which language to
I find myself doing the following a lot: C:\Code>hg pull pulling from http://server/FogBugz/kiln/Repo/Project/Rebuild/trunk searching
I see lot of new machines and laptops now having 64 bit hardware and
I see a lot of JDK 1.6 notes about how to open an HTML

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.