We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Julia Keywords
Keywords in Julia are reserved words that have a predefined meaning to the compiler. They are used for some internal processes by the compiler. Keywords can’t be used as a variable name. Doing the same will result in a compile-time error. Example:
# Julia program to illustrate
# the use of keywords
# Using 'for' keyword
fori in1:10
# Using if keyword
ifi %2==0
println(i, " is even")
# Using else keyword
else
println(i, " is odd")
# Using end keyword
end
end
Output
1 is odd
2 is even
3 is odd
4 is even
5 is odd
6 is even
7 is odd
8 is even
9 is odd
10 is even
If we use a keyword as a variable name, the compiler will generate an error:
Important keywords in Julia
baremodule
begin
break
catch
const
continue
do
else
elseif
end
export
false
finally
for
function
global
if
import
let
local
macro
module
quote
return
struct
true
try
using
while
There are some keywords like abstract type, mutable struct, primitive type which are reserved but creation of variables with abstract, mutable, primitive and type is possible.