From: Hans Sjunnesson Date: 2007-02-26T19:05:05+09:00 Subject: Re: symbol to true object On Feb 26, 10:39 am, Brian Candler wrote: > On Mon, Feb 26, 2007 at 04:19:13PM +0900, Nasir Khan wrote: > > Is there an idiom to convert the symbol :true to object true (of TrueClass)? > > BOOL_MAP = { :true=>true, :false=>false } > BOOL_MAP[sym_arg] Or class Symbol def to_bool if to_s.eql?("true") true elsif to_s.eql?("false") false else raise ArgumentError end end end :true.to_bool => true :false.to_bool => false :nothing.to_bool => ArgumentError -- Hans