In Julia, we have nothing
, which is equivalent to None
in Python. In this Answer, we'll learn about the nothing
value in Julia. Let's start with a few interesting facts about the nothing
keyword:
It is used to define a null or no value.
If a function doesn't have anything to return, it returns nothing
.
It is a reserved keyword in Julia, which means we cannot use it as a variable name.
We can assign it to a variable.
It has no type.
Let's take a look at an example.
#function that returns nothingfunction func()end#call function funcprintln(func())
Line 2: We define a func()
function where we don't return anything.
Line 6: We call the func()
function and display its return value. Since we don't return anything in the function func()
, it returns nothing
.
Free Resources