The
Python
Output:
Python
Output:

isdefined() is an inbuilt function in julia which is used to test whether the specified global variable or object field is defined or not. The passed parameters can be a module and a symbol or a composite object and field name (as a symbol) or index.
Syntax: isdefined(m::Module, s::Symbol) or isdefined(object, s::Symbol) or isdefined(object, index::Int) Parameters:Example:Returns: It returns true for the defined specified global variable or object field else returns false.
- m::Module: Specified module.
- s::Symbol: Specified symbol.
- object: Specified composite object.
- index::Int: Specified index.
# Julia program to illustrate
# the use of isdefined() method
# Getting true for the defined
# specified global variable or
# object field else returns false.
println(isdefined(Base, :sum))
println(isdefined(Base, :num))
println(isdefined(Base, :NonExistentMethod))
# Initialising a composite type value with
# Floor division operator
a = 2//3;
println(isdefined(a, 1))
println(isdefined(a, 2))
println(isdefined(a, :num))
println(isdefined(a, :numerator))
true true false true true true false
@isdefined()
The@isdefined() is an inbuilt function in julia which is used to tests whether the specified variable s is defined in the current scope or not.
Syntax: @isdefined s Parameters:Example:Returns: It returns true if the specified variable s is defined in the current scope else returns false.
- s: Specified variable.
# Julia program to illustrate
# the use of @isdefined() method
# Getting true if the specified variable
# s is defined in the current scope
# else returns false.
function f()
println(@isdefined x)
x = 10
println(@isdefined x)
end
f (generic function with 1 method)
println(f())
