Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: simple, array question!
Lloyd Linklater
9/4/2008 1:39:00 PM
hwang is wrote:
> hi! Gentlemen
>
> i don't understand array declaration..
>
> c languages, array declaration is...
>
> char str[100];
>
> but, how do i declaration an array for ruby..
>
> oo is difficult...
>
> plz teach me ..
To get a specific size of array, you specify the number of items.
ar = Array.new(100)
p ar.length
=> 100
Also, you can specify how to initialize the array.
n = 5
ar = Array.new(n, "A")
n.times {|i| p i, ar[i]}
results in:
0
"A"
1
"A"
2
"A"
3
"A"
4
"A"
I hope that helps.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: simple, array question!
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