What is the nothing value in Julia?

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.

Example

#function that returns nothing
function func()
end
#call function func
println(func())

Explanation

  • 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

Copyright ©2025 Educative, Inc. All rights reserved