# Is there a multiline ruby "comment" approach? like java's /\*

**URL:** <https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780>\
**Category:** Rails\
**Created:** [September 15, 2006, 12:41pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780 "2006-09-15T12:41:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 15, 2006, 12:41pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/1 "2006-09-15T12:41:39Z")

</div>

Hi,

Just wondering if there is a way to easy comment out a block of ruby  
code  
without putting the “#” characters on each line?

Is there an equivalent to java’s /\* \*/, for example:

/\* askdf  
asd  
fasdf  
as  
dfasd  
fa  
\*/

Thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 15, 2006, 1:11pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/2 "2006-09-15T13:11:47Z")

</div>

> Hi,
> 
> Just wondering if there is a way to easy comment out a block of ruby code  
> without putting the “#” characters on each line?
> 
> Is there an equivalent to java’s /\* \*/, for example:  
> \<…\>

=begin  
your comment…  
… going on…  
… and on…  
=end

## Regards, Rimantas

[http://rimantas.com/](http://rimantas.com/)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 15, 2006, 1:15pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/3 "2006-09-15T13:15:47Z")

</div>

excellent - thanks Rimantas

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 15, 2006, 4:54pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/4 "2006-09-15T16:54:17Z")

</div>

Am I correct in that the =begin and =end have to be on the beginning of  
a newline?

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 15, 2006, 6:18pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/5 "2006-09-15T18:18:57Z")

</div>

Yes, and as far as I know, that’s the only multi-line comment syntax in  
Ruby.

Jason

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [March 5, 2008, 1:25pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/6 "2008-03-05T13:25:15Z")

</div>

=begin  
=end

They must be the first thing on that line. No whitespace can precede it.

Jason

On Tue, Mar 4, 2008 at 5:00 PM, Tony Bianco

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [March 4, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/7 "2008-03-04T23:00:21Z")

</div>

I’m using Rails 2.0 and I tried this and this is the error I got

syntax error, unexpected ‘=’  
=begin

======== CODE ============  
def who\_bought  
=begin  
respond\_to do |format|  
format.xml {  
@product = Product.find(params[:id])  
@orders = @product.orders  
}  
end  
=end  
end  
======== END CODE ========

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [March 6, 2008, 6:35am UTC](https://www.ruby-forum.com/t/is-there-a-multiline-ruby-comment-approach-like-javas/68780/8 "2008-03-06T06:35:01Z")

</div>

thanks! That helps. I couldn’t figure out why I couldn’t get it to work.
