As for copying you can do:
phrase2 = phrase1.dup
or
# Clone: copies singleton methods as well
phrase2 = phrase1.clone
You can do this as well to avoid copying at all:
phrase2 = phrase1.gsub("Hello","Hi")
More Related Contents:
- Can’t output currency in ruby with money-gem [closed]
- Very Basic Ruby puts and gets
- What does the (unary) * operator do in this Ruby code?
- How to sort an array in descending order in Ruby
- How to debug Ruby scripts [closed]
- Converting a nested hash into a flat hash
- How can I find which operating system my Ruby program is running on?
- Optional argument after splat argument
- Gem installation error: You have to install development tools first (Windows)
- What does @@variable mean in Ruby?
- Pressing Ctrl + A in Selenium WebDriver
- You have already activated X, but your Gemfile requires Y
- What is the best way to convert an array to a hash in Ruby
- Why is the shovel operator (
- What does the question mark at the end of a method name mean in Ruby?
- How can I switch to ruby 1.9.3 installed using Homebrew?
- How to avoid “cannot load such file — utils/popen” from homebrew on OSX
- Installing Nokogiri on OSX 10.10 Yosemite
- Ruby method lookup path for an object
- What evaluates to false in Ruby?
- find_spec_for_exe’: can’t find gem bundler (>= 0.a) (Gem::GemNotFoundException)
- what is ||= in ruby? [duplicate]
- Using layouts in HAML files independently of Rails
- How to use “RVM –default” on MacOSX
- How to implement a short URL like the URLs in Twitter?
- ‘||=’ operator in Ruby
- Ruby: extend self
- How to make Sinatra work over HTTPS/SSL?
- ERROR: Error installing ffi: ERROR: Failed to build gem native extension
- What is the opposite of string.next?