Block comment problem

Hello,

For some reason I’m unable to do block comments. I keep receiving this
error in my terminal:

timesheet.rb:20: syntax error, unexpected ‘=’, expecting kEND
=begin
^
timesheet.rb:36: syntax error, unexpected ‘=’, expecting kEND
=end
^
line 20 =begin
puts “Some print statements”

line 36 =end

I have ubuntu 8.10 and rails 2.2.2

Thanks

Hi,

In message “Re: block comment problem”
on Fri, 19 Dec 2008 13:08:43 +0900, Mrmaster M.
[email protected] writes:

|For some reason I’m unable to do block comments. I keep receiving this
|error in my terminal:
|
|timesheet.rb:20: syntax error, unexpected ‘=’, expecting kEND
| =begin
| ^

“=begin” should start at the beginning of a line. You cannot indent
them.

          matz.

Thanks, that fixed the problem :slight_smile:

Matz wrote:

“=begin” should start at the beginning of a line. You cannot indent
them.

Any good reason for this?

I suppose it must be slower for Ruby to strip leading whitespace, but
only very slightly.

Why would I want to indent block comments? So they’re at the same
indentation as the code I’m commenting. Keeps things neat and tidy. :slight_smile:

Hi,

In message “Re: block comment problem”
on Sat, 20 Dec 2008 19:35:44 +0900, Dave B.
[email protected] writes:

|Matz wrote:
|> “=begin” should start at the beginning of a line. You cannot indent
|> them.
|
|Any good reason for this?

They’re not part of regular syntax, so I want clearly mark as such.
Besides that, they were designed to be used for embedded documents a la
Perl at the very early stage of Ruby development, when we didn’t have
RDoc yet. I’d rather recommend to put # signs at the top of lines.

          matz.

Dave B. wrote:

indentation as the code I’m commenting. Keeps things neat and tidy. :slight_smile:
It might be because of this conflict:

x
=begin
3/0
rescue
“div by 0”
end