输入动态常量赋值

时间:2014-03-25 02:45:16

标签: ruby string input

我可以尝试其他方法或重写我的代码吗?我再试一次。 我放弃了。

def Input
    puts("What day?")
    Date = gets.chomp
    puts("What month")
    Month = gets.chomp
    puts("What year?")
    Year = gets.chomp
    puts("Input your event?")
    Event = gets.chomp
    text = file.open("Event.txt")
    return[Date, Month, Year, Event]
end
Input

1 个答案:

答案 0 :(得分:0)

结帐highline

使用highline/import

所以它的工作方式是

require "highline/import"

def input
    arr = []
    date = ask('What day? ')
    month = ask('What Month?')
    year = ask('What Year? ')
    event = ask('What Event?')
    [data, month, year ,event]
end

input