Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

James Robertson http://www.r0bertson.co.uk

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Range validation with a Case statement in Ruby

Source: The Ruby case Statement - Techotopia [techotopia.com]
   1  score = 70
   2  
   3  result = case score
   4     when 0..40: "Fail"
   5     when 41..60: "Pass"
   6     when 61..70: "Pass with Merit"
   7     when 71..100: "Pass with Distinction"
   8     else "Invalid Score"
   9  end
  10  
  11  puts result
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS