I want to install 'shift_until_kind_of' in the global Array class
so that I can do like this:

    ary = [1, 2, "a", 3, 4, "b", 5, 6]
    assert_equal([1, 2], ary.shift_until_kind_of(String))

But extending the Array class does not work.
How should I extend the global Array class ?




module ArrayMisc
	def shift_until_kind_of(klass)
		res = []
		loop do
			data = self.first
			break if (data == nil) || data.kind_of?(klass) 
			res << data
			self.shift
		end
		res
	end
end

def test_shift_until
	#Array.extend ArrayMisc   # BOOM, does not work
	ary = [1, 2, "a", 3, 4, "b", 5, 6]
	ary.extend ArrayMisc
	res = ary.shift_until_kind_of(String)
	assert_equal([1, 2], res)
	assert_equal(["a", 3, 4, "b", 5, 6], ary)
end  


--
Simon Strandgaard