Created
May 1, 2019 15:15
-
-
Save nisevi/6bdf8147f458ca047a55d79453aab086 to your computer and use it in GitHub Desktop.
MonkeyPatch the String class for adding two new methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class String | |
def thanoscase! | |
return self if empty? | |
half_universe = length/2 | |
half_universe.times { slice!(rand(length)) } | |
self | |
end | |
def thanoscase | |
dup.thanoscase! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment