unless
suggest changeA 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents