Anonymous user
Pick random element: Difference between revisions
Add Ruby.
No edit summary |
(Add Ruby.) |
||
Line 20:
x <- runRVar (choice [1 2 3]) DevRandom</lang>
=={{header|Ruby}}==
{{works with|Ruby|1.9}}
<lang ruby>irb(main):001:0> %w(north east south west).sample
=> "west"
irb(main):002:0> (1..100).to_a.sample(2)
=> [17, 79]</lang>
{{works with|Ruby|1.8, but not 1.9}}
<lang ruby>irb(main):001:0> %w(north east south west).choice
=> "south"</lang>
=={{header|Smalltalk}}==
|