How to do it remake

	IssetX = function(ArX,x)
		indexX = true
		try
			indexX = getindex(ArX, x)
		catch
			indexX = false
		end	
		indexX
	end	
ArX = Dict(542=>1,566=>2)
IssetX(ArX,550)

x may not be in ArX, I just make an exception, maybe there is a more competent option?

First, when you declare functions that way, they are technically anonymous. I believe that accessing functions declared in global scope this way is inefficient, so you usually want to avoid this unless you really intend to to use an anonymous function bound to IssetX.

Base has the function get, which lets you define a default if the argument is not found as a key. For example

get(Arx, x, y)

This will return ArX[x] if x \in keys(ArX) else it will return y.

get!(ArX, x, y)

will do the same except it will also add y as the value of key x if x is not already a key.

2 Likes

thank you! How it all just turns out)