Sha256: 9c33b8fd59d1318bfd1e852e934dbdcd353324df53b202c9341966c7c721d0c0

Contents?: true

Size: 398 Bytes

Versions: 12

Compression:

Stored size: 398 Bytes

Contents

class Array
  def extract_options!
    if last.is_a?(Hash)
      pop
    else
      {}
    end
  end
end

module Array::Etest
  def test_extract_options
    arr = %w(1 2)
    assert_equal({}, arr.extract_options!)
    assert_equal(%w(1 2), arr)

    arr = [ 1, 2, { :a => :b }]
    assert_equal({ :a => :b }, arr.extract_options!)
    assert_equal( [ 1,  2 ], arr)
  end
end if VEX_TEST == "boot"

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vex-0.6.2 lib/vex/boot/array.rb
vex-0.4.4 lib/vex/boot/array.rb
vex-0.4.2 lib/vex/boot/array.rb
vex-0.3.3 lib/vex/boot/array.rb
vex-0.2.9 lib/vex/boot/array.rb
vex-0.2.8 lib/vex/boot/array.rb
vex-0.2.7 lib/vex/boot/array.rb
vex-0.2.6 lib/vex/boot/array.rb
vex-0.2.5 lib/vex/boot/array.rb
vex-0.2.2 lib/vex/boot/array.rb
vex-0.2.1 lib/vex/boot/array.rb
vex-0.2 lib/vex/boot/array.rb