Yes yes, I think I have found my 2nd compiler bug (not counting
realbasic). I think I found an actual bug in Ruby, on all platforms
none the less (well linux and mac).
if yu just run console or irb and do this
ph = "no.305.week"
b = ph+"5"
returns "no.305.week5"
then do
b.delete ph
and it returns empty string
If you put anything BUT 5 in the string, everything works. Also if
you substitute 305 with something that is not a number only everything
works.
I have put in more thoughts on this in my blog :
http://traustithor.blogspot.com/2010/04/most-funny-but-annoying-ruby-bug.html
If anyone can cast any idea on this as to why this is happening, I
would love to hear it. I know the bug is in the delete function, I
want some more and deeper idea as to why.
This is such an edge case.
Trausti
Yes yes, I think I have found my 2nd compiler bug (not counting
realbasic). I think I found an actual bug in Ruby, on all platforms
none the less (well linux and mac).
if yu just run console or irb and do this
ph = "no.305.week"
b = ph+"5"
returns "no.305.week5"
then do
b.delete ph
and it returns empty string
If you put anything BUT 5 in the string, everything works. Also if
you substitute 305 with something that is not a number only everything
works.
I think you misunderstand what delete is supposed to do. It does not
mean 'find occurrences of the substring and remove them'. Instead it
removes any characters present in all of the arguments, so for example
"a1b2c3d4e5".delete('12345') #=> 'abcde'
"a1b2c3d4e5".delete('12345', '123') #=> 'abcd4e5'
In your case the string b, by construction contains only characters
present in ph (since the 5 that you add at the end of it is already
present in ph)
Fred
Ah ha. That makes delete actually quite cool function. Thank you.
Trausti