From: Hiato Xaero Date: 2007-10-31T03:36:43+09:00 Subject: Re: Array and ASCII Help needed... ------=_Part_4158_10497874.1193769403513 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/30/07, Michael Linfield wrote: > > 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-forum.com/. No, sorry, not quite. The thing is I want to know the ASCII value of whatever that specific class variable is storing ie if @l = 't' then I want the ASCII value of 't', not @ which ?@l produces. Then the thing with the array is that it is an Array of an Array, ie Each master array sotres a sub array as in [1, --> [4,5,6] 2, --> [7,8,9] 3] --> [10,11,12] So calling array[1] would return an array, whereas array[1,2] should return 5 but it returns an array... ------=_Part_4158_10497874.1193769403513--