From: Trans Date: 2007-07-27T04:22:24+09:00 Subject: Re: rtrim and ltrim function for ruby: is this ok? On Jul 24, 3:55 pm, LeonB wrote: > I created this function: > > class String > def rtrim(character) > > if self[-1, 1] == character.to_s > self[0, self.length - 1] > end > return self > end > > def ltrim(character) > if self[0, 1] == character.to_s > self[1, self.length] > end > return self > end > end > > Is this ok? Am I not duplicating any built-in ruby functions? Does > anyone see any possible problems with these functions? > > Thanks in advance! #chomp! but there is no reverse or left chomp --wish there were! And it does not support regexp. Maybe worth an RCR. T.