unless

suggest change

A common statement is if !(some condition). Ruby offers the alternative of the unless statement.

The structure is exactly the same as an if statement, except the condition is negative. Also, the unless statement does not support elsif, but it does support else:

# Prints not inclusive
unless 'hellow'.include?('all')
  puts 'not inclusive'
end

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents