On Fri, Nov 5, 2010 at 10:22 AM, Alex Zinchenko <[email protected]>wrote:
> I'm using rvm on Mac OS X Snow Leopard. > ree-1.8.7-head with rails 2.3.8: > > ree-1.8.7-head > require 'rubygems' > => true > ree-1.8.7-head > require 'active_support' > => true > ree-1.8.7-head > [1,2,3].rand > DEPRECATION WARNING: Array#rand is deprecated and will be removed in > Rails 3. Use "random_element" instead. (called from irb_binding at > (irb):6) > => 2 > > That's OK. Now ruby-1.9-2-p0 with rails 3.0.1: > > ruby-1.9.2-p0 > require 'rubygems' > => true > ruby-1.9.2-p0 > require 'active_support' > => true > ruby-1.9.2-p0 > [1,2,3].rand > NoMethodError: private method `rand' called for [1, 2, 3]:Array > from (irb):3 > from /Users/yumitsu/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>' > ruby-1.9.2-p0 > [1,2,3].random_element > NoMethodError: undefined method `random_element' for [1, 2, 3]:Array > from (irb):4 > from /Users/yumitsu/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>' > > BUT: > > Loading development environment (Rails 3.0.1) > ruby-1.9.2-p0 > [1,2,3].rand > => 1 > > I just don't get it. Any ideas? > Since you're using 1.9, why not just use Array#sample? -- Erol M. Fornoles http://github.com/Erol http://twitter.com/erolfornoles http://ph.linkedin.com/in/erolfornoles -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

