# following are a few ideas on self-referential symbol to hash approaches # for http://twitter.com/danmayer/ class Symbol def to_h(&block) Hash[to_sym, block && (block.call || eval(to_s, block))] end def / value Hash[to_sym, value] end def > value Hash[to_sym, value] end end result = 42 p :result.to_h p :result.to_h{} p :result.to_h{ 42.0 } p :result > result p :result / result __END__ cfp:~ > ruby a.rb {:result=>nil} {:result=>42} {:result=>42.0} {:result=>42} {:result=>42}