Carbon Language Comments
Comments can be used to explain Carbon code and make it more readable.
They are also useful to prevent snippets of code from running, which is helpful when testing code.
Creating a Comment in Carbon
Comments can be created using a double forward slash ‘//’ at the beginning of a line of code:
// This is a comment
The double slash tells Carbon to ignore the rest of the line.
You can use comments to prevent code from executing during testing.
fn Main() -> i32 {
// Commenting out the following line will prevent Print() from executing:
// Print(“Hello World!”);
return 0;
}
Multi Line Comments in Carbon
Carbon does not (currently) have support for multi line comments.
Each line containing a comment must be started with a double forward slash:
// Use the double slash
// for every line you want to comment out