简体   繁体   English

在同一行上打印多个ruby变量

[英]Print multiple ruby variables on the same line

Is there any method to print multiple ruby variables on the same line? 有没有什么方法可以在同一行上打印多个ruby变量? Like in the example below: 像下面的例子一样:

env = gets()
name = gets()
puts "Deleting #{name} in #{env}"

I'm trying to put this variables in a system (cmd) also, and I can't set these two variables in the same line... the output is : 我也试图将此变量放在系统(cmd)中,并且无法在同一行中设置这两个变量...输出为:

Deleting name
in env

Thanks, Vlad 谢谢,弗拉德

Use 采用

env = gets().chomp
name = gets().chomp

Your code is working exactly as it should. 您的代码完全可以正常工作。 Just remove the newlines from the two strings before printing them. 只需在打印两个字符串之前删除换行符即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM