Need a randomly chosen element from an array? There’s a method for that!
Array#choice (Ruby 1.8.7) or Array#sample (Ruby > 1.8.7):
[1,2,3,4,5,6,7,8,9].choice => 5 [1,2,3,4,5,6,7,8,9].sample => 8 [1,2,3,4,5,6,7,8,9].sample(3) => [3,8,9]
Thanks to everyone who mentioned these methods here and here.
You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.