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 ww  w.  j  av a  2 s . c o m
 puts "You're too young to use this system"  
else 
 puts "You can use this system" 
end

Result

Related Topic