How to add a message to next if statement in ruby

ruby

Solution

Here it is :

next puts "#{web_url.status[0].to_i}" if x == 2 # expression here

Example :

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

Go through the documentation keywords.

Problem

How to combine `next` with `puts "#{web_url.status[0].to_i}` together and display it in console but only if `if` part is true. ``` 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 ```

Original source