On Sunday, 1 June 2003 at 2:00:29 +0900, Steven Ketcham wrote: > > Moving from C++ > > Q1.) Is there an equivalent to enumerated types? > Q2.) Is there an equivalent to the const declaration for function parameters? What prevents a function parameter from being > accidently changed? > Q3.) Is this the correct way to handle Hash containers and the objects they hold? > > Thanks! > I found the below on ruby-talk: > Here's an improved version based on input from David Alan Black and Nat > Pryce: > > module Kernel > # simple (sequential) enumerated values > def enum(*syms) > n = block_given? ? yield : 0 > syms.each_with_index { |s,i| const_set(s,i+n) } > end > > # enumerated values suitable for bitwise > # OR-ing > def set(*syms) > syms.each_with_index { |s,i| > const_set(s,2**i) } > end > end > Thanks, > Jason Voegele Is this what you are looking for? BTW, after I became rubyized, I found myself not needing solutions that were based in C/C++, and for this particular case, changed my design to use symbols. -- Jim Freeze ---------- Waste not, get your budget cut next year.