What is the difference in how Ruby initializes a new double-quoted string ( "" ) compared to String.new ? For curiosity and experimentation, I tried String#initialize :
class String def initialize puts "I <3 bananas"
I am trying to find out why these two examples are different?
# Calling the String class directly, I can declare banana love! irb(main):054:0> String.new I <3 bananas => "" # Using double quotes, this string is not as tasty :( irb(main):055:0> "" => ""
This is annoying research because every Google result seems to be oriented towards the basic Ruby syntax, and I could not find anything in the Ruby documentation.
ruby
amorphid
source share