On 8/28/05, Brian Schröäer <ruby.brian / gmail.com> wrote: > On 28/08/05, David Brady <ruby_talk / shinybit.com> wrote: > > Okay, one more question from a C++ leopard trying to change his spots: > > > > I want to set up a program that uses some predefined values to determine > > its logic. For example, a method could analyze some data and return > > "Good", "Fair", "Poor", or "Out of Bounds" based on a set of > > thresholds. I want to be able to refer to these values by name in my > > code, so constants or symbols make a good choice here. But I also want > > to build a sort of rule set around these values: some function returns > > values in the range of (0.0..1.0) and I want to be able to say that 0.8 > > is the minimum score for "Good", etc. I also want the word "Good" > > stored in a specific single place so that I don't make any typos each > > time I need to print the description. > > > > In C++, I would use an enum for each of the values, then build arrays of > > floats and strings indexed by those enums to hold the thresholds and > > descriptions. > > > > What's the Ruby idiom for this? > > Try this link: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/150439 See if it helps pth