# Legal syntax, bug or what?

**URL:** <https://www.ruby-forum.com/t/legal-syntax-bug-or-what/67208>\
**Category:** Ruby\
**Created:** [September 1, 2006, 11:53am UTC](https://www.ruby-forum.com/t/legal-syntax-bug-or-what/67208 "2006-09-01T11:53:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathan2000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/fbc32d/32.png) [@jonathan2000](https://www.ruby-forum.com/u/jonathan2000)\
**Post date:** [September 1, 2006, 11:53am UTC](https://www.ruby-forum.com/t/legal-syntax-bug-or-what/67208/1 "2006-09-01T11:53:44Z")

</div>

Hi all,

I’m still working on Ripper and during my explorations I came across a  
line of code in mkmf.rb that I can’t wrap my head around.

## Line 1313

```
opts = $arg_config.collect {|t, n| "\t#{t}#{"=#{n}" if n}\n"}

```

* * *

## When I copy-paste the entire method to a file and run it through Ruby everything is fine. However irb doesn’t accept the method:

## irb(main):001:0\> def mkmf\_failed(path) irb(main):002:1\> unless $makefile\_created or File.exist?(“Makefile”) irb(main):003:2\> opts = $arg\_config.collect {|t, n| “\t#{t}#{”=#{n}" if n}\n"} irb(main):004:3\* abort “\*\*\* #{path} failed \*\*\*\n” + FailedMessage + opts.join irb(main):005:3\> end irb(main):006:2\> end irb(main):007:1\>

As you can see irb doesn’t detect the end of the third line.

After taking the statement apart and simplifying it, it all boils down  
to the following construction:  
#{"=#{n}" if n}  
inside the ““main”” double-quoted string.

Why does ruby accept this construct while irb doesn’t?  
Doesn’t Ruby see the first double-quote as the end of the string?

Any clarification would be greatly appreciated.

With kind regards  
Jonathan M.

---

<div class="post-metadata">

**Author:** ![jonathan2000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/fbc32d/32.png) [@jonathan2000](https://www.ruby-forum.com/u/jonathan2000)\
**Post date:** [September 1, 2006, 12:35pm UTC](https://www.ruby-forum.com/t/legal-syntax-bug-or-what/67208/2 "2006-09-01T12:35:56Z")

</div>

Hi –

On Fri, 1 Sep 2006, Jonathan M. wrote:

> When I copy-paste the entire method to a file and run it through Ruby  
> irb(main):006:2\> end  
> Doesn’t Ruby see the first double-quote as the end of the string?
> 
> Any clarification would be greatly appreciated.

Nested #{} are allowed, so this is some kind of irb parsing glitch.  
It seems to be the = that’s confusing irb for some reason:

irb(main):002:0\> “#{“hello#{}”}”  
=\> “hello”  
irb(main):003:0\> “#{“hello=#{}”}”  
irb(main):004:0\*

I believe it’s causing the second # to be interpreted as introducing a  
comment.

David
