user10627032
user10627032

Reputation:

Nested multiline comments in ruby?

I'm fairly new to ruby. I've noticed that multiline comments are not nestable. This code causes an error:

=begin
=begin
=end
=end

this is the error:

SyntaxError: (irb):4: syntax error, unexpected '='
    from C:/Ruby/bin/irb.cmd:19:in `<main>'

Is there a way to nest comments in ruby?

Upvotes: 4

Views: 434

Answers (1)

Nick Ellis
Nick Ellis

Reputation: 1077

I don't believe there is. The problem ruby sees here is like this:

=begin   # start comment
=begin   # still commenting
=end     # end commenting
=end     # wtf is this?

Upvotes: 4

Related Questions