Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用.concat将随机整数追加到字符串_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 使用.concat将随机整数追加到字符串

Ruby on rails 使用.concat将随机整数追加到字符串,ruby-on-rails,ruby,Ruby On Rails,Ruby,我尝试将从方法获得的整数附加到字符串,我尝试了多种不同的方法:更改这两行: slotThread.concat( machineSlot.to_s) #if x was entered the slotThread appends a random number puts slotThread #slotThreads current process 到 这叫做字符串插值,在ruby中经常使用 顺便说一句,您使用CamelCase来命名变量和方法,这不是惯例。不紧急,但我会在

我尝试将从方法获得的整数附加到字符串,我尝试了多种不同的方法:更改这两行:

  slotThread.concat( machineSlot.to_s)
  #if x was entered the slotThread appends a random number

  puts slotThread
  #slotThreads current process

这叫做字符串插值,在ruby中经常使用


顺便说一句,您使用CamelCase来命名变量和方法,这不是惯例。不紧急,但我会在你有时间的时候检查。

也许你应该慢一点。Thread='你的号码是:'在while循环之外?这太尴尬了。。谢谢你的评论thohi@user2010884我的回答有用吗?
  slotThread.concat( machineSlot.to_s)
  #if x was entered the slotThread appends a random number

  puts slotThread
  #slotThreads current process
puts "#{slotThread}#{machineSlot}"