Thursday, November 4, 2010

[Rails] Problem with Array.rand

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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate