Get the item at key or null if key is not in the map.

var x = new HashMap[String, Int]
x["four"] = 4
assert x.get_or_null("four") == 4
assert x.get_or_null("five") == null

Note: use has_key and [] if you need the distinction between a key associated with null, and no key.

Property definitions

core $ MapRead :: get_or_null
	# Get the item at `key` or null if `key` is not in the map.
	#
	#     var x = new HashMap[String, Int]
	#     x["four"] = 4
	#     assert x.get_or_null("four") == 4
	#     assert x.get_or_null("five") == null
	#
	# Note: use `has_key` and `[]` if you need the distinction between a key associated with null, and no key.
	fun get_or_null(key: nullable Object): nullable V
	do
		if has_key(key) then return self[key]
		return null
	end
lib/core/collection/abstract_collection.nit:545,2--557,4

core $ HashMap :: get_or_null
	redef fun get_or_null(key)
	do
		var c = node_at(key)
		if c == null then
			return null
		else
			return c._value
		end
	end
lib/core/collection/hash_collection.nit:236,2--244,4