如何将 next
与 puts "#{web_url.status[0].to_i}
组合在一起并在控制台中显示它,但前提是 if
部分为真。
tried:
next if ... && puts "{web_url.status[0].to_i}"
web_url = open(url, :proxy => BaseParser::PROXY, "User-Agent" => BaseParser.rand_ua_string() )
next if web_url.nil?
next if web_url.status[0].to_i == 410
next if web_url.status[0].to_i == 310
next if web_url.status[0].to_i == 404
next if web_url.status[0].to_i == 530
最佳答案
在这里:
next puts "#{web_url.status[0].to_i}" if x == 2 # expression here
示例:
x = 1
until x > 3
next puts("#{x} matched"),x+=1 if x == 2
puts "this iteration has number #{x}"
x += 1
end
# >> this iteration has number 1
# >> 2 matched
# >> this iteration has number 3
浏览文档 keywords .
关于ruby - 如何在ruby中的下一个if语句中添加一条消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20733364/