Keywords in Julia are reserved words whose value is pre-defined to the compiler and can not be changed by the user. These words have a specific meaning and perform their specific operation on execution.
'local' keyword in Julia is used to create a variable of a limited scope whose value is local to the scope of the block in which it is defined.
var1 = value1 loop condition statement local var1 statement end
ERROR: LoadError: UndefVarError: x not defined
Above code generates error because the socpe of variable x is limited to the scope of for-loop in which it is defined.
2 4 6 8 10 0
In the above code, it can be seen that when the value of x is printed within the loop, the output is as per condition, but when the value of x is printed outside the scope of for-loop, the value of x is again 0 as assigned earlier. This shows that the scope of the local variable remains limited to the block in which it is defined.
- Julia global Keyword | Creating a global variable in Julia
- Julia end Keyword | Marking end of blocks in Julia
- Julia function keyword | Create user-defined functions in Julia
- Julia continue Keyword | Continue iterating to next value of a loop in Julia
- Julia break Keyword | Exiting from a loop in Julia
- if keyword - Conditional evaluation in Julia
- Julia return keyword
- try keyword - Handling Errors in Julia
- else keyword in Julia
- Creating array with repeated elements in Julia - repeat() Method
- Creating a view of parent array in Julia - view(), @view and @views Methods
- Creating a copy of elements from a collection to an array in Julia - copyto!() Method
- Creating a similar type of array in Julia - similar() Method
- How to Setup Julia Path to Environment Variable?
- Getting ceiling value of x in Julia - ceil() Method
- Getting floor value of x in Julia - floor() Method
- Getting the minimum value from a list in Julia - min() Method
- Package Management in Julia
- Visualisation in Julia
- Random Numbers Ecosystem in Julia - The Pseudo Side
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.