puts "What year you was born ?" while true year = gets.chomp if year == # 请问这里应该怎样写呢? return true else puts " ***only input number***" end end
正则行吗?
简单版:year =~ /^\d+$/
year =~ /^\d+$/
:)
#1 楼 @cxh116 只能是数字 return true 应该怎样写呢
#3 楼 @chankaward
... 看你自己需求了,比如你可以直接年龄给打印出来 puts year
puts year
还好没积分,不然搞得我像是在刷积分一样