[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/16/2005 12:51:00 AM

James Edward Gray II [mailto:james@grayproductions.net] wrote:

#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)

in prgg, one generally does not know what is contained in x (otherwise, one
would not have to ask for it); so, how does one know what char (code) is in
x?

i only showed that

?x will not work, but

x[0] will

#
#> btw, is there a Char class?
#
#No, there's not. See Integer#chr.

i was looking for the other way around, like Chr#integer.

thanks james and kind regards -botp

#
#James Edward Gray II
#
#




2 Answers

James Gray

4/16/2005 12:56:00 AM

0

On Apr 15, 2005, at 7:50 PM, Peña, Botp wrote:

> #> btw, is there a Char class?
> #
> #No, there's not. See Integer#chr.
>
> i was looking for the other way around, like Chr#integer.

We've just been playing with examples of that:

String#[char_index]

James Edward Gray II




James Gray

4/16/2005 1:54:00 AM

0

(Thinking about this some more...)

On Apr 15, 2005, at 7:50 PM, Peña, Botp wrote:

> in prgg, one generally does not know what is contained in x
> (otherwise, one
> would not have to ask for it); so, how does one know what char (code)
> is in
> x?

You type "x" when you want a string literal. That is not related to
variable x, naturally. Similarly, :x is a symbol literal, again not
related to any variable x. That leaves us with ?x being a simple
character literal. Make sense?

James Edward Gray II