Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

A Simple Case Example

DZone's Guide to

A Simple Case Example

·
Free Resource
Source: Class: Range [ruby-doc.org]

 
  
Returns true if obj is an element of rng, false otherwise. Conveniently, === is the comparison operator used by case statements.

  
   case 79
   when 1..50   then   print "low\n"
   when 51..75  then   print "medium\n"
   when 76..100 then   print "high\n"
   end

produces:

   high


 
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}