From: Paul Smith Date: 2009-09-08T18:19:22+09:00 Subject: Re: i need to strip \n and nil I think 7stud is being sarcastic... He thinks the compact is unnecessary, and is explaining his point by introducing other unnecessary elements like inject. On Tue, Sep 8, 2009 at 1:08 AM, Ken Bloom wrote: > On Tue, 08 Sep 2009 03:50:24 +0900, 7stud -- wrote: > >> Ken Bloom wrote: >>> On Mon, 07 Sep 2009 05:27:10 +0900, Bigmac Turdsplash wrote: >>> >>>> im sending files back and forth form a client and a server using >>>> sockets, >>>> >>>> the first string the server sends to the client is the size of the >>>> file, "59023" >>>> >>>> the client recives this string in this format "59023\n", nil >>>> >>>> i need to trim \n and nil from the string so i can do some math with >>>> the string... >>> >>> ["59023\n", nil].compact.collect{|x| x.chomp} >> >> Didn't you really mean: >> >> ["59023\n", nil].inject("") {|acc, elmt| >> "#{acc}#{elmt}"}.match(/\n/).pre_match > > No, that's not quite the same at all. (I did exactly what he asked for in > the subject line.) > > > > -- > Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. > Department of Computer Science. Illinois Institute of Technology. > http://www.iit.edu/~kbloom1/ > > > -- Paul Smith http://www.nomadicfun.co.uk paul@pollyandpaul.co.uk