I want the monkeypatch Ruby String class to provide shuffle and shuffle! methods shuffle! .
class String def shuffle self.split('').shuffle.join end end
Returns a new line. How to write a shuffle! method shuffle! which modifies the string instead of returning a copy?
I tried to figure it out myself, but the String source code is in C in the MRI.
source share