Ruby - case when statement

Introduction

Consider the following code:

Demo

fruit = "orange" 
case fruit #   w  w w. j a v  a2s  .c  om
 when "orange" 
 color = "orange" 
 when "apple" 
 color = "green" 
 when "banana" 
 color = "yellow" 
 else 
 color = "unknown" 
end

Related Topics