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:
for i in 1 : 10
if i % 2 = = 0
println(i, " is even" )
else
println(i, " is odd" )
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.
Last Updated :
26 Mar, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...