# Ruby coding question

**URL:** <https://www.ruby-forum.com/t/ruby-coding-question/47503>\
**Category:** Rails\
**Created:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/ruby-coding-question/47503 "2005-11-12T12:49:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixelmech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df788c/32.png) [@pixelmech](https://www.ruby-forum.com/u/pixelmech)\
**Post date:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/ruby-coding-question/47503/1 "2005-11-12T12:49:14Z")

</div>

I have a question about ruby code delimiters.

This code block:

\<% end -%\>

What does the “-” before the ending delimiter signify? My code errored  
out, I thought those were  
misprints or something in the book, but added them and it works. I don’t  
recall seeing that in the  
Ruby appendix, and I’ve never seen this convention before (like with JSP  
or ASP).

TIA

Tom

[http://www.pixelmech.com/](http://www.pixelmech.com/)

---

<div class="post-metadata">

**Author:** ![pixelmech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df788c/32.png) [@pixelmech](https://www.ruby-forum.com/u/pixelmech)\
**Post date:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/ruby-coding-question/47503/2 "2005-11-12T12:49:14Z")

</div>

Hi,

Tom Dell’Aringa wrote:

> \<% end -%\>
> 
> What does the “-” before the ending delimiter signify? My code errored out, I thought those were  
> misprints or something in the book, but added them and it works. I don’t recall seeing that in the  
> Ruby appendix, and I’ve never seen this convention before (like with JSP or ASP).

Simply prunes the \n after ‘end’.

---

<div class="post-metadata">

**Author:** ![pixelmech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df788c/32.png) [@pixelmech](https://www.ruby-forum.com/u/pixelmech)\
**Post date:** [November 12, 2005, 12:49pm UTC](https://www.ruby-forum.com/t/ruby-coding-question/47503/3 "2005-11-12T12:49:15Z")

</div>

— Jean-Christophe M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Simply prunes the \n after ‘end’.

Thanks - Had I literally read the next line… 😕 I would have known  
that. Nice feature though!

Tom

[http://www.pixelmech.com/](http://www.pixelmech.com/)

---

<div class="post-metadata">

**Author:** ![pixelmech](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df788c/32.png) [@pixelmech](https://www.ruby-forum.com/u/pixelmech)\
**Post date:** [November 24, 2005, 2:57pm UTC](https://www.ruby-forum.com/t/ruby-coding-question/47503/4 "2005-11-24T14:57:41Z")

</div>

Tom:

the final -%\> differs from %\> in that if there is no text produced  
between the delimiters then it takes no space on the page. I believe  
the standard delimiter %\> would take up some space whether or not it  
needed to. A good example of when this may be useful (I used it the  
other day) is if you were making invoices and had something like

\<% org.company\_name %\> #no need for fancy delimiter as all  
companies will have names  
\<% org.address1 %\> #as above  
\<% org.address2 -%\> #note fancy delimiter because many  
companies don’t have an address2 and we don’t want a blank line  
appearing in the address.

bruce
