From: Paul Smith Date: 2009-09-25T23:16:27+09:00 Subject: Re: Roulette & rand On Fri, Sep 25, 2009 at 3:09 PM, Aldric Giacomoni wrote: > Symbols are a good habit to get into because they always represent a > unique object, the symbol, while strings always create a new object. > irb(main):009:0> 0.object_id > => 1 > irb(main):010:0> 0.object_id > => 1 > irb(main):011:0> "0".object_id > => 21396750 > irb(main):012:0> "0".object_id > => 21393440 > > If we're gonna talk about code simplification.. > > colors = { 0 => :green } > (1..36).each { |num| colors[num] = (num % 2 == 0) ? :black : :red } > > But I'm also lazy, and this is actually slower than the way you guys > generate your hash... And also different, as the red and black numbers aren't the odd and even numbers. > -- > Posted via http://www.ruby-forum.com/. > > -- Paul Smith http://www.nomadicfun.co.uk paul@pollyandpaul.co.uk