Open In App

Comments in Julia

Improve
Improve
Like Article
Like
Save
Share
Report

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: 
Example: 
 

Python




# This is a comment 
# Print "GeeksforGeeks !" to console 
print("GeeksforGeeks") 


Output: 
 

Comments-Output-01

In the above code, the compiler ignores the statement written after #, because it considers the line as a comment and skips its execution. 
 

Multi-Line Comments

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: 
 

Python




#= This would be a multiline comment in Julia that 
spans several lines and describes geeksforgeeks. 
A Computer Science portal for geeks. It contains  
well written, well thought  
and well-explained computer science  
and programming articles,  
quizzes and more.
=# print("GeeksForGeeks")


Output: 
 

Comments-Output-02

In the above code snippet, the statements that are enclosed within #= and =# are considered as comments and are ignored by the compiler at the time of Code execution.
 


Last Updated : 11 Feb, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads