The index of the first occurrence of item.

Return -1 if item is not found. Comparison is done with ==.

var a = [10,20,30,10,20,30]
assert a.index_of(20)   == 1
assert a.index_of(40)   == -1

Property definitions

core $ SequenceRead :: index_of
	# The index of the first occurrence of `item`.
	# Return -1 if `item` is not found.
	# Comparison is done with `==`.
	#
	#     var a = [10,20,30,10,20,30]
	#     assert a.index_of(20)   == 1
	#     assert a.index_of(40)   == -1
	fun index_of(item: nullable Object): Int do return index_of_from(item, 0)
lib/core/collection/abstract_collection.nit:945,2--952,74

core $ AbstractArrayRead :: index_of
	redef fun index_of(item) do return index_of_from(item, 0)
lib/core/collection/array.nit:64,2--58

pthreads $ ConcurrentSequenceRead :: index_of
	redef fun index_of(index)
	do
		mutex.lock
		var r = real_collection.index_of(index)
		mutex.unlock
		return r
	end
lib/pthreads/concurrent_collections.nit:212,2--218,4