Method: String#shuffle
- Defined in:
- lib/extra/string.rb
#shuffle ⇒ Object
Randomly shuffle a string.
Example: 'foobar'.shuffle #=> bofoar
Returns: String
18 19 20 |
# File 'lib/extra/string.rb', line 18 def shuffle split(//u).sort_by { rand }.join('') end |