Ruby - Statement unless statement

Introduction

unless can work in exactly the same way because unless is just the opposite of if:

Demo

age = 10 
unless age >= 18 # from w  w w .j  av  a  2 s .co  m
   puts "You're too young to use this system" 
   puts "So we're going to exit your program now" 
   exit 
end

Result

Related Topics