Knight's Travails (#27)

#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

···

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

···

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

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