Sha256: 4f0cff6b65ba1be0cf0cdc82851df053298cd0df808efa9d02a1e4147b270b03
Contents?: true
Size: 440 Bytes
Versions: 3
Compression:
Stored size: 440 Bytes
Contents
require 'facet/array/rand_index' class String # Destructive pick_char. Delete a random character of the string # and return it as a single-character string. # # require 'facet/string/at_rand' # # s = "Ruby rules" # s.pick_char! #=> "y" # s #=> "Rub rules" # def rand_char! c = split(//,-1) i = c.rand_index r = c[ri] c[ri] = '' self.replace( c.join('') ) return r end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-0.7.0 | lib/facet/string/rand_char%21.rb |
facets-0.7.1 | lib/facet/string/rand_char%21.rb |
facets-0.7.2 | lib/facet/string/rand_char%21.rb |