# indexable.rb

Path: | lib/core/facets/indexable.rb
Last Update: | Mon Dec 05 22:58:33 +0000 2011

# Indexable

Indexable is a mixin that provides index based methods, working soley with four methods: index, slice, splice and size.

These methods work in harmony. Where index returns a position of a given element, slice returns elements for given positions. splice is like slice but replaces the given position with new values. This mehtod is not part of ruby core, but it generally just an alias for #[]=, just as slice is an alias of #[]. size of course simply returns the total length of the indexable object.

NOTE: To test the folowing methods Indexable needs to be included into Array and array must have splice defined.

      require 'facets/array/splice'

      class ::Array
        include Indexable
      end

CREDIT: Thomas Sawyer

[Validate]