In this answer to a separate question , I said that if you do
name = "Rohit " "Sharma"
you do not create two objects Stringwith contents "Rohit "and "Sharma"that combine to create a new String object with contents "Rohit Sharma", but you only create one String object to start with.
But this is only a book telling me this, not a manual check.
How could you write line creation?
I tried to use
set_trace_func proc { |event, file, line, id, binding, classname|
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
string = "Insert content here"
But received only
c-return -:3 set_trace_func Kernel
line -:5
And "Programming Ruby 1.9" (The Pickaxe) says the change Class#newwill not work for strings, as they are built without use new.
source
share