Ruby - if else statement

Introduction

if and unless supply the else condition, used to delimit lines of code that you want to be executed if the main expression is false:

Demo

age = 10 
if age < 18 # from  w  ww. ja  va 2  s .  c om
 puts "You're too young to use this system"  
else 
 puts "You can use this system" 
end

Result

Related Topic