[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [rcr] String#split behaves odd

Peña, Botp

12/7/2004 7:33:00 AM

Yukihiro Matsumoto [mailto:matz@ruby-lang.org] wrote:
//|[] != [""]
//|
//|I myself thought that string#split would return an array of
//strings w a
//|minimum element of [""]
//
//I don't get it. [] is an array of strings with zero elements. ;-)
//

I'm sorry, but the ff disturbs me (only):

irb(main):014:0> "testing".split("test")
=> ["", "ing"]
irb(main):015:0> " ".split("test")
=> [" "]
irb(main):016:0> "".split("test")
=> []

Also, I cannot seem to get just an array of empty string [""] using split.
I'm ashame to ask sir Matz, so can anyone kindly give me an example?

// matz.
//

kind regards -botp