Sha256: 6b45e9db885e1850822b93a9350fa6f13f702566b610fd12a9ff275990e453dc

Contents?: true

Size: 499 Bytes

Versions: 4

Compression:

Stored size: 499 Bytes

Contents

#	This file is part of the "Utopia Framework" project, and is released under the MIT license.
#	Copyright 2010 Samuel Williams. All rights reserved.
#	See <utopia.rb> for licensing details.

class Array
	def find_index(&block)
		each_with_index do |item, index|
			if yield(item)
				return index
			end
		end
		
		return nil
	end
	
	def split_at(&block)
		index = find_index(&block)
		
		if index
			return [self[0...index], self[index], self[index+1..-1]]
		end
		
		return [[], nil, []]
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
utopia-0.10.0 lib/utopia/extensions/array.rb
utopia-0.9.61 lib/utopia/extensions/array.rb
utopia-0.9.60 lib/utopia/extensions/array.rb
utopia-0.9.59 lib/utopia/extensions/array.rb