Sha256: eb6c24d177feb82cea45c829a38cacb88c60e83160431c2afd6f95a222b77e56

Contents?: true

Size: 398 Bytes

Versions: 3

Compression:

Stored size: 398 Bytes

Contents

class String

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

  # 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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.0 lib/core/facets/string/splice.rb
facets-2.2.1 lib/core/facets/string/splice.rb
facets-2.3.0 lib/core/facets/string/splice.rb