May 12, 2021 Ruby
Comments are comment lines within Ruby code that are ignored at run time. A single-line comment starts with the character , until the line ends, as follows:
When executed, the above program produces the following results:
Hello, Ruby!
You can comment on more than one line using the syntax of s begin and s end, as follows:
#!/usr/bin/ruby -w puts "Hello, Ruby!" =begin 这是一个多行注释。 可扩展至任意数量的行。 但 =begin 和 =end 只能出现在第一行和最后一行。 =end
When executed, the above program produces the following results:
Hello, Ruby!
Make sure that the comments at the end are enough distance from the code to make it easy to distinguish between comments and code. I f there is more than one tail comment in the block, align them. For example:
@counter # 跟踪页面被击中的次数 @siteCounter # 跟踪所有页面被击中的次数