【发布时间】:2017-09-30 10:10:38
【问题描述】:
有没有办法在 Ruby 中进行编码,以便终端显示两个选项,用户需要使用箭头键选择并使用 Enter 确认?
伪代码:
p "What is the capital of Scotland?
user_select = gets.chomp
p "Edinburgh"
p "Glasgow"
if user_select == "Edinburgh" etc etc
我想知道这是否可以在用户无需输入答案的情况下实现。终端可以像 GUI 一样工作吗?
【问题讨论】: