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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 17, 10:27 am, Trausti Thor Johannsson <traust...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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> > I have put in more thoughts on this in my blog :http://traustithor.blogspot.com/2010/04/most-funny-but-annoying-ruby-... > > 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 > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ah ha. That makes delete actually quite cool function. Thank you. Trausti On Sat, Apr 17, 2010 at 12:48 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 17, 10:27 am, Trausti Thor Johannsson <traust...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> 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 >> >> I have put in more thoughts on this in my blog :http://traustithor.blogspot.com/2010/04/most-funny-but-annoying-ruby-... >> >> 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 >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.