This works
irb(main):001:0> name = "Rohit " "Sharma"
=> "Rohit Sharma"
But this doesn’t
irb(main):001:0> fname = "Rohit "
=> "Rohit "
irb(main):002:0> lname = "Sharma"
=> "Sharma"
irb(main):003:0> name = fname lname
It gives this error
NoMethodError: undefined method `fname' for main:Object
from (irb):3
Please provide some suggestions.
Thanks in advance.
UPDATE
After getting the answers I have written a blog post. Please check it out.
The error is related to the fact that
fnamewould have to be a function for this to work. Instead, tryor even
but where you had
it is a special case, since Ruby will join the two strings automatically.