Ruby - case when statement

Introduction

Consider the following code:

Demo

fruit = "orange" 
case fruit # from   w  w w  . j a v  a 2s .  c  o m
 when "orange" 
 color = "orange" 
 when "apple" 
 color = "green" 
 when "banana" 
 color = "yellow" 
 else 
 color = "unknown" 
end

Related Topics