From: John Winters Date: 2008-08-01T23:23:01+09:00 Subject: Re: problem with "starts_with?" Skave Rat wrote: [snip] > So I'd just like to add > > def starts_with?(prefix) > prefix = prefix.to_s > self[0, prefix.length] == prefix > end > > to my code where I can use it on all strings inside. Surely you just do it? (Or have I missed the point somehow?) class String def starts_with?(prefix) prefix = prefix.to_s self[0, prefix.length] == prefix end end candidate = "Banana" puts candidate.starts_with?("Da").to_s Just make sure the first bit gets executed somewhere early on in your application's run. HTH John -- Posted via http://www.ruby-forum.com/.