Hey,
As a bit of a fun project I'm implementing a Beatnik interpreter in Ruby. If you've never heard of Beatnik it's an esoteric programming language in which operations are specified by the "scrabble score" of the words in the source code.
Anyway, the implementation requires a different operation to happen for different scrabble scores. This isn't particularly to implement, one obvious ways is an if statement:
if score == 1
...
elsif score == 2
...
else
...
end
Another way would be to use a case statement:
case score
when 1
...
when 2
...
else
...
end
But neither of these two methods strikes me as particularly elegant, can you suggest an alternative way of implementing this?