From: Raito Yitsushi Date: 2010-12-17T18:20:58+09:00 Subject: Re: do your bit for my mental health - how to find the difference between two strings? On Dec 14, 7:15 pm, Iain Barnett wrote: > Hi, > > I have a piece of code that doesn't work in a Sinatra app I've been writing that doesn't work. > > These two forms don't work: > > get '/tweets/:service/' do > >   mymethod( params[:service] ) > .. > > get '/tweets/:service/' do > >   service = params[:service] >   mymethod( service ) > .. > > This works: > > get '/tweets/:service/' do > >   mymethod( 'servicename' ) > > so does this: > > get '/tweets/:service/' do > >   service = 'servicename' >   mymethod( service ) > > Using the params[:service] variable then mymethod fails to do what I expect. If I hard-code the string that it's supposed to represent, it works. Every way I've examined this variable it looks exactly the same as a hard-coded version. Dump, inspect, to_s, length, class, equality, they all give the answer I expect - it's a String, and it is the same string that's in the URL that's been passed. I know that the method being called works, the only thing that doesn't is this variable. Nothing touches it before the method is called. I've tried via telnet too, no difference. > > To help me keep the small grain of sanity I (hope to) have remaining, could anyone suggest a good way to find out what makes two strings different? > > I'm currently reading stuff on using the debugger, along with some stuff on Rack Test, but if anyone has a useful insight I can use I'd be very, very grateful. Would I best running a test through the debugger, for example? > > Regards > Iain Did you try lcs-diff?