本文简要介绍ruby语言中 OptionParser::Arguable.getopts
的用法。
用法
getopts(*args)
getopts 的替代方法如下。另请参阅 OptionParser#getopts
。
def getopts(*args)
($OPT = ARGV.getopts(*args)).each do |opt, val|
eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val"
end
rescue OptionParser::ParseError
end
相关用法
- Ruby ArgumentError类用法及代码示例
- Ruby Array.push用法及代码示例
- Ruby Array.hash用法及代码示例
- Ruby Array permutation()用法及代码示例
- Ruby Array.to_a用法及代码示例
- Ruby Array.to_h用法及代码示例
- Ruby Array.to_s用法及代码示例
- Ruby Array class fill()用法及代码示例
- Ruby Array.array + other_array用法及代码示例
- Ruby Array product()用法及代码示例
- Ruby Array zip()用法及代码示例
- Ruby Array concat()用法及代码示例
- Ruby Array类用法及代码示例
- Ruby Array.take()用法及代码示例
- Ruby Array.reject!用法及代码示例
- Ruby Array.flatten!用法及代码示例
- Ruby Array.reject用法及代码示例
- Ruby Array compact!()用法及代码示例
- Ruby Array reject!()用法及代码示例
- Ruby Array.repeated_permutation()用法及代码示例
- Ruby Array.index()用法及代码示例
- Ruby Array.pack()用法及代码示例
- Ruby Array.rassoc(obj)用法及代码示例
- Ruby Array.values_at()用法及代码示例
- Ruby Array repeated_combination()用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Arguable.getopts。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。