YouTip LogoYouTip

Ruby Comment

# Ruby Comments Comments are lines within Ruby code that are ignored at runtime. Single-line comments start with the # character and continue until the end of the line, as shown below: ## Example #!/usr/bin/ruby -w# This is a single-line comment.puts"Hello, Ruby!" [Run Example Β»](#) When executed, the above program will produce the following result: Hello, Ruby! ## Ruby Multi-line Comments You can use **=begin** and **=end** syntax to comment multiple lines, as shown below: ## Example #!/usr/bin/ruby -w puts"Hello, Ruby!"=begin This is a multi-line comment. It can span any number of lines. But =begin and =end must appear on the first and last lines, respectively. =end When executed, the above program will produce the following result: Hello, Ruby! Please ensure that trailing comments are sufficiently separated from the code to easily distinguish comments from code. If there is more than one trailing comment, align them. For example: ## Example @counter# Tracks the number of times the page is clicked.@siteCounter# Tracks the number of times all pages are clicked.
← Ruby DecisionRuby Operator β†’