gpt4 book ai didi

ruby - Ruby 中的多行注释?

转载 作者:数据小太阳 更新时间:2023-10-29 06:16:05 26 4
gpt4 key购买 nike

如何在 Ruby 中注释多行?

最佳答案

#!/usr/bin/env ruby

=begin
Every body mentioned this way
to have multiline comments.

The =begin and =end must be at the beginning of the line or
it will be a syntax error.
=end

puts "Hello world!"

<<-DOC
Also, you could create a docstring.
which...
DOC

puts "Hello world!"

"..is kinda ugly and creates
a String instance, but I know one guy
with a Smalltalk background, who
does this."

puts "Hello world!"

##
# most
# people
# do
# this


__END__

But all forgot there is another option.
Only at the end of a file, of course.
  • 这就是它的外观(通过屏幕截图)- 否则很难解释上述评论的外观。 点击放大:

Comments in a text-editor

关于ruby - Ruby 中的多行注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2989762/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com