Jeff Schwab
8/15/2006 4:43:00 AM
Ken Bloom wrote:
> On Mon, 14 Aug 2006 14:05:11 +0000, Jeffrey Schwab wrote:
>> def begin_comment(s)
>> # Ignore it. It's a comment.
>> end
>>
>> begin_comment <<end_comment # Comment until end of comment.
>> This is a string that's actually serving
>> as a multi-line comment.
>> end_comment
> If you're going to take this approach (and =begin =end is probably better)
> then there's no need to define a method. simply use a heredoc that won't
> get used:
>
> <<end_comment
> The comment started with the previous line
>
> and ends when the heredoc ends
> end_comment
That generates a nasty warning:
main.rb:1: warning: useless use of a literal in void context
> Of course, this won't work correctly as the last line in a method, so use
Good point.
> (=begin...=end) as other posters have described.
Or, if at all feasible, actually comment each line.