James ha scritto: > Hi, > > I've done much OO coding in perl 5 and I'm > making the move over to ruby. > > Gosh, don't your programs get shorter! > > What would be a good ruby idiom to move efficiently from > a positive integer in the range 0 to ~2000 to a specific > method call? > > A case / when statement would do this simply, but in perl > I sped this up by building a lookup table using > an array containing references to the appropriate perl subs. people already gave you good answers, so I am her with a question :) Why do you want that? Supposing you have 2000 autogenerated methods, you could put them in a module named like: method_xxxx and just call them with module.send "method_#{number}" or something like that, and avoid the intermediary array/hash, but it seem strange to me to have all that method named as "numbers"