Tag Archives: ruby

Ruby shovel operator: What the?!

This is taken from the Ruby Koans. It’s the shovel operator, and it appends stuff to a string.


    original_string = "Hello, "
    hi = original_string
    there = "World"
    hi << there

So I'm totally down with the idea that hi now equals "Hello, World". No problem. But in fact, original_string also now equals "Hello, World". That is totally messed up! :)

But seriously. What is up with that? is there way to not find this just... just... shocking?!