Johnny's Software Saloon

Weblog where I discuss things that really interest me. Things like Java software development, Ruby, Ruby on Rails, Macintosh software, Cocoa, Eclipse IDE, OOP, content management, XML technologies, CSS and XSLT document styling, artificial intelligence, standard document formats, and cool non-computing technologies.

My Photo
Name:
Location: Germantown, Maryland, United States

I like writing software, listening to music (mostly country and rock but a little of everything), walking around outside, reading (when I have the time), relaxing in front of my TV watching my TiVo, playing with my cat, and riding around in my hybrid gas/electric car.

Monday, February 06, 2006

Handy way of mapping values in Ruby

There is something I like about Ruby that you can do in some languages but not most languages.

Here is an example:


grade = case points
when 94..100 then :A
when 83..93 then :B
when 75..82 then :C
when 65..74 then :D
else :F
end


You can do something very similar in LISP using the COND function and in MUMPS using the $SELECT function. Most languages do not have something this convenient.

0 Comments:

Post a Comment

<< Home

Related pages & news