Ruby编程基础:从词法到语法的全面解析
1. 词法结构
1.1 嵌入式文档与注释
嵌入式文档以 =begin 开头, =end 结尾,且 = 必须是每行的第一个字符。它可用于在程序中包含长篇文档或嵌入其他语言的源代码。例如:
=begin Someone needs to fix the broken code below!
Any code here is commented out
=end
文档注释通常位于方法、类和模块定义之前,可使用 ri 工具浏览, rdoc 工具可将其提取并格式化为 HTML。注释可写成多行注释(每行以 # 开头),也可写成以 =begin rdoc 开头的嵌入式文档。以下是一个示例:
#
# Rdoc comments use a simple markup grammar like those used in wikis.
#
# Separate paragraphs with a blank line.
#
# = Headings
#
# Headings begin with an equals sign
#
# == Sub-Headings
# The line above produces a subheading.
# === Su
超级会员免费看
订阅专栏 解锁全文
9

被折叠的 条评论
为什么被折叠?



