Mega Code Archive

 
Categories / Ruby / String
 

Override the method from String Class

class String   def scramble     (split //).sort_by { rand }.join   end end class UnpredictableString < String   def scramble     (split //).sort_by { rand }.join   end   def inspect     scramble.inspect   end end str = UnpredictableString.new("this is a test.") puts str