Problem with Ruby string concatenation

后端 未结 3 2057
Happy的楠姐
Happy的楠姐 2021-01-05 09:11

This works

irb(main):001:0> name = \"Rohit \" \"Sharma\"
=> \"Rohit Sharma\"

But this doesn\'t

irb(main):001:0> fn         


        
3条回答
  •  春和景丽
    2021-01-05 09:54

    Just put a + inbetween them like

    name = fname + lname
    

    string + string is defined to return a new string containing the two inputs concatenated together.

提交回复
热议问题