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? -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 5, 2010 at 10:22 AM, Alex Zinchenko <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erol Fornoles wrote in post #959483:> 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/erolfornolesArray.sample is OK, but what about backward compatibility? -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 5, 2010 at 10:35 AM, Alex Zinchenko <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Array.sample is OK, but what about backward compatibility?Array#rand should be fine if you''re only using it inside a Rails app (and not with a decoupled ActiveSupport). Btw, you might be interested in this: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4555 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erol Fornoles wrote in post #959486:> Array#rand should be fine if you''re only using it inside a Rails app > (and > not with a decoupled ActiveSupport). > > Btw, you might be interested in this: > https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4555 > > > -- > Erol M. Fornoles > http://github.com/Erol > http://twitter.com/erolfornoles > http://ph.linkedin.com/in/erolfornolesThank you, Erol! Now I understood - they removed both Array#rand and Array#random_element since Array#sample presents in stdlib. Thank you again. -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.