我有一个计划,将创建工作笔记对我来说,它的工作原理,但有一个尾随破折号,我想摆脱:如何摆脱尾随破折号
def prompt(input)
print "[#{Time.now.strftime('%T')}] #{input}: "
STDIN.gets.chomp
end
def work_performed
count = 0
notes = ''
while true
input = prompt("Enter work notes[#{count += 1}]")
notes << "\n" + "#{input}\n"
if input.empty?
return notes
else
while input.empty? != true
input = prompt('Enter work notes[*]')
notes << " - #{input}\n"
end
end
end
end
在运行时:
test
- tset
-
test
- tset
-
tset
- tset
-
我该如何重构这个以消除关卡末端的尾部短划线?
这是美丽的。 –
我很乐意提供帮助。 –