core :: SequenceRead :: get_or_null
null
if the index
is invalid.var a = [10,20,30]
assert a.get_or_null(1) == 20
assert a.get_or_null(3) == null
assert a.get_or_null(-1) == null
assert a.get_or_null(-10) == null
# Try to get an element, return `null` if the `index` is invalid.
#
# ~~~
# var a = [10,20,30]
# assert a.get_or_null(1) == 20
# assert a.get_or_null(3) == null
# assert a.get_or_null(-1) == null
# assert a.get_or_null(-10) == null
# ~~~
fun get_or_null(index: Int): nullable E
do
if index >= 0 and index < length then return self[index]
return null
end
lib/core/collection/abstract_collection.nit:902,2--915,4