【问题标题】:Input dynamic constants assignment [duplicate]输入动态常量分配[重复]
【发布时间】:2014-03-25 10:58:59
【问题描述】:

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

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

【问题讨论】:

  • 这里没有理由使用常量,使用datemonth等即可。

标签: ruby string input


【解决方案1】:

结帐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

【讨论】:

  • /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- highline/import (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' from DateTime.rb:3:in `
    '
  • 你安装了highline吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多