Hi --

On Tue, 1 Jun 2004, Florian Gross wrote:

> David Alan Black wrote:
> > Hi --
> 
> Moin!
> 
> >>FYI:  I have no idea when this wiping empty tail elements are useful.
> >>Any ideas ?
> > 
> > Maybe a case like:
> > 
> >   irb(main):006:0> "one two three ".split(" ")
> >   => ["one", "two", "three"]
> > 
> > (though there you don't need an argument to split at all I guess) or
> > something like:
> > 
> >   irb(main):016:0> "one!two!three!".split("!")
> >   => ["one", "two", "three"]
> 
> Hm, I think that it causes more trouble than it's worth. 

I'm not sure what you mean; what trouble does it cause?

> It's very easy to remove empty elements anyway:
>
> 	"one!two!three!".split("!").reject { |item| item.empty? }

It's even easier than that :-)

  "one!two!three!".split("!").grep(/\S/)

though I'm still not sure what's undesireable about having split do
different things.

> Maybe it would be better to create a reject_at_end/at_start or something 
> similar?

That seems like an awfully specific case for a whole separate method.
(I admit, though, that I'm somewhat conservative about proliferation
of methods :-)


David

-- 
David A. Black
dblack / wobblini.net