From: Brian Candler Date: 2003-05-29T17:35:05+09:00 Subject: Re: Array.extend versus instance.extend Incidentally, you can make your class more general-purpose by using ===, noting that klass1 === obj is true if obj.is_a?(klass1) i.e. case obj when klass1 # this is executed if klass1 === obj end I'm not sure exactly what you'd call it (I seem to remember this naming problem occured for Test::Unit as well), but you'd have something like: module ArrayMisc def shift_until_match(caseitem) res = [] loop do break if caseitem === self.first res << self.shift end res end end # Then you can do: class Array; include ArrayMisc; end a = [0,1,"two","three","four","five"] b = a.shift_until_match(String) p a,b #>> ["two", "three", "four", "five"] [0, 1] b = a.shift_until_match(/^f/) p a,b #>> ["four", "five"] ["two", "three"] Regards, Brian.