Ruby - case when statement

Introduction

Consider the following code:

Demo

fruit = "orange" 
case fruit #  ww w  .ja  va2  s  .co m
 when "orange" 
 color = "orange" 
 when "apple" 
 color = "green" 
 when "banana" 
 color = "yellow" 
 else 
 color = "unknown" 
end

Related Topics