Ruby switch like idiom
Posted
by Eef
on Stack Overflow
See other posts from Stack Overflow
or by Eef
Published on 2010-04-02T10:45:42Z
Indexed on
2010/04/02
10:53 UTC
Read the original article
Hit count: 307
Hey,
I have recently started a project in Ruby on Rails. I used to do all my projects before in Python but decided to give Ruby a shot.
In the projects I wrote in Python I used a nice little technique explained by the correct answer in this post:
http://stackoverflow.com/questions/277965/dictionary-or-if-statements-jython
I use this technique due to Python not having a native switch function and it also get rid of big if else blocks
I have been trying to do recreate the above method in Ruby but can't seem to quite get it.
Could anyone help me out?
Thanks
Eef
© Stack Overflow or respective owner