home PYTHONJAVA
 

Ruby comment

Comments are comment lines within Ruby code that are ignored at runtime. Single-line comments begin with the # character until the end of the line, as follows:

Instance

#!/usr/bin/ruby -w # This is a one-line comment. puts "Hello, Ruby!"

When executed, the above program will produce the following results:

Hello, Ruby!

Ruby multi-line comments

You can annotate multiple lines using the =begin and =end syntax as follows:

Instance

#!/usr/bin/ruby -w puts "Hello, Ruby!" =begin This is a multi-line comment. Can be extended to any number of rows. But =begin and =end can only appear on the first and last lines. =end

When executed, the above program will produce the following results:

Hello, Ruby!

Make sure that the trailing comments are far enough away from the code to make it easier to distinguish between comments and code. If the tail exceeds a comment, align them. For example:

Instance

@counter # Tracking the number of times a page was clicked @siteCounter # Track the number of times all pages were clicked





welookups is optimized for learning.© welookups. 2018 - 2019 All Right Reserved and you agree to have read and accepted our term and condition.