[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Knight's Travails (#27

Peña, Botp

4/15/2005 6:44:00 AM

Matthew D Moss [mailto:matthew.moss@gmail.com] wrote:

#Well, I used 'a'[0] cause I'm still a Ruby-newbie. I was
#unaware of the ?a construct.

imho, you thought it right.

irb(main):001:0> x='a'
=> "a"
irb(main):003:0> x[0]
=> 97
irb(main):004:0> ?x
=> 120
irb(main):005:0> ?a
=> 97

I myself seldom use ? notation.

btw, is there a Char class?


kind regards -botp


1 Answer

James Gray

4/15/2005 1:33:00 PM

0

On Apr 15, 2005, at 1:44 AM, Peña, Botp wrote:

> Matthew D Moss [mailto:matthew.moss@gmail.com] wrote:
>
> #Well, I used 'a'[0] cause I'm still a Ruby-newbie. I was
> #unaware of the ?a construct.
>
> imho, you thought it right.
>
> irb(main):001:0> x='a'
> => "a"
> irb(main):003:0> x[0]
> => 97
> irb(main):004:0> ?x
> => 120
> irb(main):005:0> ?a
> => 97

I'm not completely sure what you are trying to show here. ?x means the
character code for the letter x. This has nothing to do with the
variable x. (That's not an issue because you're naming your variables
better than that, right? :D)

> btw, is there a Char class?

No, there's not. See Integer#chr.

James Edward Gray II