On Fri, 13 Jul 2001, ts wrote:

> p> You can even get rid of the dubious ' - [""]' by changing the code to
> p> "a b c :d e f".split(/\s+:(\S.*)|\s+/)
>
>  One use of '- [""]' is for
>
Don't forget the implied Array#uniq with Array#-:

ruby -e 'p " a b c :d e f".split(/\s+:(\S.*)|\s+/) - [""]'
["a", "b", "c", "d e f"]

is ok, but

ruby -e 'p " a a c :d e f".split(/\s+:(\S.*)|\s+/) - [""]'
["a", "c", "d e f"]

may not be what you expected.
It is not the same as

ruby -e 'p " a a c :d e f".split(/\s+:(\S.*)|\s+/)'
["", "a", "a", "c", "d e f"]

ruby -e 'p ["", "a", "a", "c", "d e f"].delete_if {|i| "" == i}'
["a", "a", "c", "d e f"]

Compare:
     ["a", "c", "d e f"]
["a", "a", "c", "d e f"]


=========================================================
Jim Freeze
jim / freeze.org
---------------------------------------------------------
No comment at this time.
http://www.freeze.org
=========================================================