为什么我的循环不起作用?

Jen*_*ert 0 ruby loops

我无法让这个程序正确响应用户输入.各种循环技术,或者只运行一次块或无限无论运行块用户输入(我试过什么casewhile也).这是我尝试过的最新方法:

work_summary = []
begin
  # code that runs a sprint and adds results to the work_summary array
  puts "Would you like to add a sprint, Y/N?"
  sprint = gets.to_s
end until sprint == "N"
print work_summary, "\n"
Run Code Online (Sandbox Code Playgroud)

Ruby永远不会使用任何各种方法反对我的语法,但它也永远不会有效.

Unc*_*ene 5

你需要

sprint = gets.chomp
Run Code Online (Sandbox Code Playgroud)

获取返回字符串,尾随"\n".