Though your IDE may think you're commenting out the whole line, you're
not.  It's the proper way to do string interpolation.

See here: http://www.zenspider.com/Languages/Ruby/QuickRef.html#6

Or, optionally, the Pickaxe book section on strings.

--Jeremy

On 12/6/07, Peter Loftus <loftuz / gmail.com> wrote:
> if /#{var1}/ =~ line
>
> when i enter # thats just comments out the whole line
> any reason for using #
>
> Jeremy McAnally wrote:
> > You can use string interpolation like you can with double quoted
> > strings.
> >
> > var1 = "hello"
> >
> > File.foreach "file.txt" do |line|
> >  if /#{var1}/ =~ line
> >    puts "found it"
> >    break
> >  end
> > end
> >
> --
> Posted via http://www.ruby-forum.com/.
>
>


-- 
http://www.jeremymcanally.com/

My books:
Ruby in Practice
http://www.manning.com/mcanally/

My free Ruby e-book
http://www.humblelittlerubybook.com/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/