Ruby annotation
Note hides a row for the Ruby interpreter, or part of a line, or several rows. You can use the character (#) at the beginning of the line:
# I'm a note, please ignore me.
Alternatively, the annotation can follow the same line as the statement or expression:
Name = "Madisetti" # This is also a comment
You can annotate multiple lines, as follows:
# This is a note.
# This is also a comment.
# This is also a comment.
# This is still a note.
Here is another form. This block annotation hides the line between =begin/=end for the interpreter:
=begin
This is a comment.
This is also a comment.
This is also a comment.
This is still a comment.
=end
Ruby Chinese Code
with Ruby output "Hello, world!", English is no problem, but if you output Chinese characters "Hello, the World" may encounter Chinese coding problems.
If no encoding is specified in the Python file, an error occurs during execution:
#!/usr/bin/ruby-w
puts "Hello, world!" ";
The results of the above program output are:
The above error message shows that Ruby uses ASCII code to read the source code, Chinese will appear garbled, the solution is as long as the beginning of the file to join the #-*-Coding:utf-8-*-(emac) or #coding =utf-8 on the line.
Instance
#!/usr/bin/ruby-w
#-*-coding:utf-8-*-
puts "Hello, world!" ";
The output results are:
So if you are learning the process, the source code file, if the inclusion of Chinese code, you need to pay attention to two points:
1. You must add the #-*-Coding:utf-8-*-in the first line, telling the interpreter to use Utf-8 to parse the source.
2. You must set the editor to save the file encoded as Utf-8.