# Block comment problem

**URL:** <https://www.ruby-forum.com/t/block-comment-problem/156001>\
**Category:** Ruby\
**Created:** [December 19, 2008, 5:16am UTC](https://www.ruby-forum.com/t/block-comment-problem/156001 "2008-12-19T05:16:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@mrmaster](https://www.ruby-forum.com/u/mrmaster)\
**Post date:** [December 19, 2008, 5:16am UTC](https://www.ruby-forum.com/t/block-comment-problem/156001/1 "2008-12-19T05:16:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mrmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@mrmaster](https://www.ruby-forum.com/u/mrmaster)\
**Post date:** [December 19, 2008, 5:25am UTC](https://www.ruby-forum.com/t/block-comment-problem/156001/2 "2008-12-19T05:25:16Z")

</div>

Hi,

In message “Re: block comment problem”  
on Fri, 19 Dec 2008 13:08:43 +0900, Mrmaster M.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

```

---

<div class="post-metadata">

**Author:** ![mrmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@mrmaster](https://www.ruby-forum.com/u/mrmaster)\
**Post date:** [December 19, 2008, 5:29am UTC](https://www.ruby-forum.com/t/block-comment-problem/156001/3 "2008-12-19T05:29:21Z")

</div>

Thanks, that fixed the problem 🙂

---

<div class="post-metadata">

**Author:** ![mrmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@mrmaster](https://www.ruby-forum.com/u/mrmaster)\
**Post date:** [December 20, 2008, 11:43am UTC](https://www.ruby-forum.com/t/block-comment-problem/156001/4 "2008-12-20T11:43:56Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![mrmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@mrmaster](https://www.ruby-forum.com/u/mrmaster)\
**Post date:** [December 22, 2008, 2:22am UTC](https://www.ruby-forum.com/t/block-comment-problem/156001/5 "2008-12-22T02:22:19Z")

</div>

Hi,

In message “Re: block comment problem”  
on Sat, 20 Dec 2008 19:35:44 +0900, Dave B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

```

---

<div class="post-metadata">

**Author:** ![mrmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@mrmaster](https://www.ruby-forum.com/u/mrmaster)\
**Post date:** [December 20, 2008, 9:04pm UTC](https://www.ruby-forum.com/t/block-comment-problem/156001/6 "2008-12-20T21:04:59Z")

</div>

Dave B. 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
