Ruby教程
Ruby控制语句
Ruby高级

Ruby 注释

Ruby 注释

Ruby 注释是程序中不可执行的行。这些行被解释器忽略,因此它们在程序执行时不会执行。它们由程序员编写以解释他们的代码,以便其他查看代码的人能够以更好的方式理解它。
Ruby 注释的类型:
单行注释 多行注释

Ruby 单行注释

Ruby 单行注释用于一次仅注释一行。它们用 # 字符定义。
语法:
#this is single line comment.
示例:
i = 10  #Here i is a variable. 
puts i
输出:
Ruby Comments 1

使用Ruby多行注释一次评论多行。它们以 =begin 开头和 =end 定义在行尾。
语法:
=begin
    this
    is
    multi line
    comment
=end
示例:
=begin 
we are declaring 
a variable i 
in this program 
=end 
i = 10 
puts i
输出:
Ruby Comments 2

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4