On Mar 31, 2004, at 7:49 PM, Simon Strandgaard wrote:

> While upgrading and reinstalling misc modules I regulary use, I bumped
> into this construction.  I don't know if the recent switch from GNU to
> Oniguruma has broken anything ?
>
> Any reason that String isn't allowed anymore ?

This behavior was kind of "promised" starting from 1.8:

[mac.gfbm:51]bystr> irb
irb(main):001:0> "aaa" !~ "bbb"
(irb):1: warning: string =~ string will be obsolete; use explicit regexp
=> true
irb(main):002:0>
[mac.gfbm:52]bystr> ruby -v
ruby 1.8.1 (2003-12-25) [powerpc-darwin]


>
>
> server> ruby a.rb
> a.rb:1:in `=~': type mismatch: String given (TypeError)
>         from a.rb:1
> server> expand -t2 a.rb
> if "hello" !~ "l{2}"
>   raise
> end
> server>
>
>
> Changing right argument into a regexp makes it work.
>
> server> ruby a.rb
> server> expand -t2 a.rb
> if "hello" !~ /l{2}/
>   raise
> end
> server> ruby -v
> ruby 1.9.0 (2004-03-31) [i386-freebsd5.1]
> server>
>
> Perhaps change exception message to something else, for instance:
> in `!~': right argument must be Regexp, but was String (TypeError)
>
> That would be less confusing ;-)
>
> --
> Simon Strandgaard
>
>

Sincerely,
Gennady Bystritsky