Sha256: 6cded9e50fc9044e5a5e90069adc3ab631901d8df0165b369a4f548066cbccb9

Contents?: true

Size: 399 Bytes

Versions: 5

Compression:

Stored size: 399 Bytes

Contents

class String

  # Like #slice, but writes rather than reads.
  # Like #store, but acts like slice!
  # when given only one argument.
  #
  #   a = "HELLO"
  #   a.splice(1)    #=> "E"
  #   a              #=> "HLLO"
  #
  #   CREDIT: Trans

  def splice(*args)
    if args.size == 1
      slice!(*args)
    else
      store(*args)
    end
  end

  # Alias for []=.
  alias_method :store, :[]=

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facets-2.4.0 lib/facets/string/splice.rb
facets-2.4.1 lib/facets/string/splice.rb
facets-2.4.2 lib/core/facets/string/splice.rb
facets-2.4.3 lib/core/facets/string/splice.rb
facets-2.4.4 lib/core/facets/string/splice.rb