[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Array and ASCII Help needed...

Michael Linfield

10/30/2007 3:30:00 PM

Hiato Xaero wrote:
> Hello there,
>
> I have just recently started Ruby (because it is such a beautiful
> language)
> and was just about two things (NOTE: I have a very strong Delphi
> background
> so the code may not be the Ruby way of ding things)
>
> 1st : How one would extract the ASCII value from an Object variable, for
> example
> @l = @txt[k,1]
> @n = ?@l
> where
> @n = 0
> The problem with that is that I end up merely extracting the ascii value
> for
> '@' and get errors for trying to something it with unknown 'l'

anything after the '?' returns an ascii value, ie ?1 returns the ascii
for 1


>
> 2nd : How does one tell Ruby to give a variable (integer) a particular
> number from an array, for example
> @n = @@da[p,@n]
> where
> @@da = [[]]
> is the equivilent of the Delphi way (which works with puts in Ruby) but
> it
> automatically makes @n an array instead of just that single value...

brackets in ruby specific an array. if you wanted to say pull a single
element out of an array it would be something as follows:

@n = [1,2,3,4,5]

@n[2] # => 3 #array elements begin from 0 in ruby, so array element 2
would be 3
I dont know if this is what you were refering to, if not, elaborate.

>
> Please comment/suggest/criticise where necissary
>
> Thanks anywho
> Hiato

--
Posted via http://www.ruby-....