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