Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: How to convert a String to an Array?
Peter Szinek
3/16/2007 12:28:00 PM
RubyCrazy wrote:
> Is there a way to convert a String to an Array? I could only find the
> following -
> 'hello world'.scan(/./)
And what's the problem with that? Or do you want a different result?
Alternatively you can do
'hello world'.split(' ')
or
'hello world'.split(/\s+/)
if you want to split on any number of whitespace chars.
If you want to split just on single spaces, your original solution is
faster.
Cheers,
Peter
__
http://www.rubyra...
:: Ruby and Web2.0 blog
http://s...
:: Ruby web scraping framework
http://rubykitch...
:: The indexed archive of all things Ruby
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: How to convert a String to an Array?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password