Sha256: dbfad696e0f3c4a3e06bf1734bf11abb494e3e813b67e41848d5bd9ab0510a27

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

# = Array Manipulation Extensions
#
# General array manipulation extensions.

#
class Array

  # Alias for <tt>|</tt>.
  alias_method :merge, :|

  # In place #merge.
  #
  def merge!( other )
    self.replace( self | other )
  end

end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TestArray < Test::Unit::TestCase

    def test_merge
      a = [1,2,3]
      b = [3,4,5]
      assert_equal( [1,2,3,4,5], a.merge(b) )
    end

    def test_merge!
      a = [1,2,3]
      b = [3,4,5]
      a.merge!(b)
      assert_equal( [1,2,3,4,5], a )
    end

    def test_rotate
      a = [1,2,3]
      assert_equal( [3,1,2], a.rotate, 'clockwise' )
      assert_equal( [2,3,1], a.rotate(-1), 'counter-clockwise' )
    end

    def test_rotate!
      a = [1,2,3]
      a.rotate!
      assert_equal( [3,1,2], a, 'clockwise' )
      a.rotate!(-1)
      assert_equal( [1,2,3], a, 'counter-clockwise' )
    end

  end

=end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-2.0.0 lib/core/facets/array/merge.rb
facets-2.0.1 lib/core/facets/array/merge.rb