maeshimaの日記

メモ書きです

Array#rand

これは便利。

require "activesupport"
puts ["hoge", "fuga"].rand #=> hogeとfugaのどちらかがランダムに表示される

追記

Array#rand is deprecated and will be removed in Rails 3. Use "random_element" instead

さらに追記

Array#random_element is deprecated and will be removed in Rails 3. Use Array#sample instead.