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}"