Forum: Ruby block comment problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fceacbe62c32d679cb1fe535ed7fa70c?d=identicon&s=25 Mrmaster Mrmaster (mrmaster)
on 2008-12-19 05:16
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
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2008-12-19 05:25
(Received via mailing list)
Hi,

In message "Re: block comment problem"
    on Fri, 19 Dec 2008 13:08:43 +0900, Mrmaster Mrmaster
<mrsolarlife@gmail.com> 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.
Fceacbe62c32d679cb1fe535ed7fa70c?d=identicon&s=25 Mrmaster Mrmaster (mrmaster)
on 2008-12-19 05:29
Thanks, that fixed the problem :)
9d751d4cd704a4efe3a335c77c4487a3?d=identicon&s=25 Dave Bass (dogsbody)
on 2008-12-20 11:43
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. :-)
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2008-12-20 21:04
(Received via mailing list)
Dave Bass wrote:
> indentation as the code I'm commenting. Keeps things neat and tidy. :-)
It might be because of this conflict:

x \
   =begin
     3/0
   rescue
     "div by 0"
   end
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2008-12-22 02:22
(Received via mailing list)
Hi,

In message "Re: block comment problem"
    on Sat, 20 Dec 2008 19:35:44 +0900, Dave Bass
<davebass@musician.org> 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.
This topic is locked and can not be replied to.