Wrap value x in an object of type Nullable, which indicates whether a value is present. Nullable(x) yields a non-empty wrapper, and Nullable{T}() yields an empty instance of a wrapper that might contain a value of type T.


  1. Wrap a value in a Nullable object:

    julia> nullable_value = Nullable(42)

    This example wraps the value 42 in a Nullable object of type Int64.

  2. Create an empty Nullable object:

    julia> nullable_empty = Nullable{Float64}()

    This example creates an empty Nullable object of type Float64 that does not contain any value.

  3. Check if a Nullable object is empty:
    julia> nullable_value = Nullable("Julia")
    julia> isnull(nullable_value)
    julia> nullable_empty = Nullable{Bool}()
    julia> isnull(nullable_empty)

    isnull can be used to check if a Nullable object is empty or contains a value.

Common mistake example:

julia> nullable_value = Nullable()
ERROR: MethodError: no method matching Nullable()

In this example, the Nullable function is called without providing a value or specifying a type. The correct usage is either Nullable(x) to wrap a value or Nullable{T}() to create an empty Nullable object with a specified type.

See Also

BigFloat, BigInt, Dict, eltype, fieldtype, Float32, Float64, IntSet, isa, isalnum, isalpha, isascii, iseltype, isequal, isgraph, isimmutable, isinteractive, isleaftype, isnull, ispunct, isspace, issubtype, keytype, Nullable, NullException, promote_type, typeintersect, typejoin, typemax, typemin, typeof, Val, valtype,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: