我试图根据用户输入在一个范围之间生成一个随机数,问题是当我运行该程序时,程序似乎将一个数字存储在指定的范围之外。在下面的示例中,我输入8并'puts ex_val‘返回247.5。class Example
example_range = gets.chomp
case example_range
when 11
程序应该将用户输入的用户名/密码与文件(userdatabase)进行比较--我想我是对的。puts "What will be your password?"password = gets.chomp
puts "Please repeat your password."username = gets.
我两天前才开始研究Ruby语言,很快就了解到我太局限于C派生语言的思维定势了……我正在尝试对字符串进行如下比较: action = gets'down
' is not a valid command at this time.那么,这是否意味着按Enter键也会存储为命令提示符输入中的新行?谁能告诉我如何实现它,这样字符串比较才能正常工作?