Sha256: 4f5be518896dfd0dae8df50d89373f4cbff1c208a887093aaf2bba719383690c

Contents?: true

Size: 352 Bytes

Versions: 3

Compression:

Stored size: 352 Bytes

Contents

require 'facet/string/rand_index'
class String
  # Destructive rand_byte. Delete a random byte of _self_ and return it.
  #
  #   require 'facet/string/rand_byte%21'
  #
  #   s = "Ruby rules"
  #   s.rand_byte!  #=> 121
  #   s             #=> "Rub rules"
  #
  def rand_byte!
    i = rand_index
    rv = self[i,1]
    self[i,1] = ''
    rv
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/string/rand_byte%21.rb
facets-0.7.1 lib/facet/string/rand_byte%21.rb
facets-0.7.2 lib/facet/string/rand_byte%21.rb