From: Shri Borde Date: 2009-02-06T02:56:17+09:00 Subject: [ruby-core:21861] Re: Regexp interpolation does not give equality Yes, I realized this later. Substitution always uses to_s, and to_s of a Regexp uses the (?-mix:) form. And equality of Regexps just looks at the regexp string, and does not try to do anything more fancy. -----Original Message----- From: Ondrej Bilka [mailto:neleai@seznam.cz] Sent: Wednesday, February 04, 2009 11:21 PM To: ruby-core@ruby-lang.org Subject: [ruby-core:21851] Re: Regexp interpolation does not give equality On Thu, Feb 05, 2009 at 12:32:11AM +0100, Shri Borde wrote: > Any idea why the second expression results in false? Its seems like both the regexpes are similar (to_s gives the same result), but the == method just fails to realize that they are really identical. irb(main):001:0> a="a" => "a" irb(main):002:0> b=/#{a}/ => /a/ irb(main):003:0> c=/#{b}/ => /(?-mix:a)/ > > irb(main):001:0> re = /Hello/ > => /Hello/ > irb(main):002:0> /#{re}/ == /Hello/ > => false > irb(main):002:0> /#{re}/.to_s == /Hello/.to_s > => true > irb(main):003:0> str = "Hello" > => "Hello" > irb(main):004:0> /#{str}/ == /Hello/ > => true > > Thanks, > Shri > -- transient bus protocol violation