Skip to content

Instantly share code, notes, and snippets.

@nisevi
Created May 1, 2019 15:15
Show Gist options
  • Save nisevi/6bdf8147f458ca047a55d79453aab086 to your computer and use it in GitHub Desktop.
Save nisevi/6bdf8147f458ca047a55d79453aab086 to your computer and use it in GitHub Desktop.
MonkeyPatch the String class for adding two new methods
# 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