Comments are the statements in a code that are ignored by the compiler at the time of execution. These statements are written to beautify the code, providing an explanation for the steps that are used in the code. During coding, proper use of comments makes maintenance easier and finding bugs easily.
In Julia, comments are used in a similar manner as in Python. Comments can be of two types, based on their usage. These are:
- Single Lined comments
- Multi lined comments
Comments are generally used for the following purposes:
- Code Readability
- Explanation of the code or Metadata of the project
- Prevent execution of code
- To include resources
Single Line Comments
Single line comments in Julia start with the hashtag symbol(#) and lasts till the end of the line. If the comment exceeds one line then put a hashtag on the next line and continue the comment. Julia’s single lined comments are useful for supplying short explanations for function declarations, variables, and expressions. See the following code snippet demonstrating single line comment:
In the above code, the compiler ignores the statement written after #, because it considers the line as a comment and skips its execution.
Julia multi-line comment is a piece of text enclosed in a delimiter (#=) on start of the comment and (=#) on the end of the comment. A multiline comment is useful when the comment text does not fit into one line; therefore needs to span across lines. Multi-line comments or paragraphs serve as documentation for others reading your code. See the following code snippet demonstrating multi-line comment:
In the above code snippet, the statements that are inclosed within #= and =# are considered as comments and are ignored by the compiler at the time of Code execution.
- 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
- Julia local Keyword | Creating a local variable in Julia
- Julia global Keyword | Creating a global variable in Julia
- 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
- Accessing element at a specific index in Julia - getindex() Method
- Get size of string in Julia - sizeof() Method
- Reverse a string in Julia - reverse() Method
- Fill an array with specific values in Julia | Array fill() method
- Accessing each element of a collection in Julia - foreach() Method
- Counting number of elements in an array in Julia - count() Method
- Julia Language Introduction
- Checking for true values in an array in Julia - any() and all() Methods
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.