Array TypeError: can't convert Fixnum into String

后端 未结 6 1864
半阙折子戏
半阙折子戏 2021-01-01 10:04

I am experimenting with arrays, and am reading the book \"Beginning Ruby on Rails\" by Steve Holzner. I made the program:

array = [\'Hello\', \'there\', 1, 2         


        
6条回答
  •  误落风尘
    2021-01-01 10:55

    Haven't tried this myself, but try replacing

    puts array2[0] + " " + array2[1]
    

    with

    puts array2[0] + " " + array2[1].to_s
    

提交回复
热议问题