From: Robert Dober Date: 2007-05-08T21:33:43+09:00 Subject: Re: general purpose chomp? On 5/8/07, Michal Suchanek wrote: > I wonder why we do not have one. Or maybe I just overlooked something? > > class String > def lstripc c = ' \r\t\n' > c = c.chr if c.kind_of? Integer > idx = 0 > while c.include? self[idx] > idx += 1 > end > self[idx..-1] > end > end > > Thanks > > Michal > > Some random thoughts * Chomp strips on the RHS of the string, right? * Sometimes I would just use sub /^/, "" (or a potential #delete as suggested in my RCR idea ;) * I feel rgxs should be accepted as params * I do not like the use a string with character set semantics (again kindly have a look at the RCR thread where somebody smarter than me has made a very good point about this). That all said, this might actually be a nice feature to have, but maybe there are just to many methods there, already doing *almost* the same. This is basically one of the reasons against my RCR idea too. Cheers Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw