Sha256: e8a8a12f8f77554ef0d89b210c25718396b68a3a07d4453bd1d75bf044f907d3

Contents?: true

Size: 346 Bytes

Versions: 10

Compression:

Stored size: 346 Bytes

Contents

# TITLE:
#
#   Splice
#
# SUMMARY:
#
#   Like #slice, but writes rather than reads.
#
# CREDIT:
#
#   - Thomas Sawyer

#
class String

  alias_method :store, :[]=

  # Like #store, but acts like slice!
  # when given only one argument.

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

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.0.0 lib/core/facets/string/splice.rb
facets-2.0.1 lib/core/facets/string/splice.rb
facets-2.0.2 lib/core/facets/string/splice.rb
facets-2.0.5 lib/core/facets/string/splice.rb
facets-2.1.0 lib/core/facets/string/splice.rb
facets-2.1.1 lib/core/facets/string/splice.rb
facets-2.0.4 lib/core/facets/string/splice.rb
facets-2.1.2 lib/core/facets/string/splice.rb
facets-2.0.3 lib/core/facets/string/splice.rb
facets-2.1.3 lib/core/facets/string/splice.rb