When I run what looks like the same command, I get the following error.
irb(main):001:0> "cat o' 9 tails" =~ '\d'
TypeError: type mismatch: String given
from (irb):1:in `=~'
from (irb):1
I have tried this on a couple of different environments but always
Ruby 1.8.4. Can anyone provide me with any insight as to why I don't
get the nil return value?
When I run what looks like the same command, I get the following error.
irb(main):001:0> "cat o' 9 tails" =~ '\d'
TypeError: type mismatch: String given
from (irb):1:in `=~'
from (irb):1
I have tried this on a couple of different environments but always
Ruby 1.8.4. Can anyone provide me with any insight as to why I don't
get the nil return value?
Tim Kuntz wrote:
> The Ruby doc states the following for a String#=~
>
> "cat o' 9 tails" =~ '\d' #=> nil
>
> When I run what looks like the same command, I get the following error.
>
> irb(main):001:0> "cat o' 9 tails" =~ '\d'
> TypeError: type mismatch: String given
> from (irb):1:in `=~'
> from (irb):1
>
> I have tried this on a couple of different environments but always
> Ruby 1.8.4. Can anyone provide me with any insight as to why I don't
> get the nil return value?
>
> tim
According to the "Programming Ruby" book, at least one operand must be
a Regexp. Older versions of Ruby would convert the second operand to a
Regexp if both were Strings.
Does anyone happen to know what version this changed with?
> from (irb):1
>
> I have tried this on a couple of different environments but always
> Ruby 1.8.4. Can anyone provide me with any insight as to why I don't
> get the nil return value?
>
> tim
"cat o' 9 tails" =~ /\d/
ie. Ruby Doc is wrong?
More likely just outdated. What "Ruby Doc" are you reading? I believe
this behavior changed between 1.6 and 1.8.
I have tried this on a couple of different environments but always
Ruby 1.8.4. Can anyone provide me with any insight as to why I don't
get the nil return value?
tim
"cat o' 9 tails" =~ /\d/
ie. Ruby Doc is wrong?
More likely just outdated.
Maybe, but it *should* be getting regenerate each night after fetching the source from cvs
···
On 5/26/06, mitchell <fs8206@yahoo.com> wrote:
--
James Britt
"I was born not knowing and have had only a little
time to change that here and there."
- Richard P. Feynman