Martin DeMello
4/14/2005 5:25:00 AM
Simon.Mullis@equinoxsolutions.com wrote:
>
> If I want to convert in the other direction - i.e get the ASCII value
> for the characters (1..9)...
>
> 1.upto(9) { |x| puts ?x }
>
> Does not work - it give me the ASCII code for x (which is 120) nine
> times
>
> How can I force ruby to treat the "x" as a variable and not as "x". ($x
> from perlland)
Just to clarify things, the ?<char> notation is a literal value, not a
function call of any sort. It's analogous to constructs like 0xFF
(literal hex number) or for that matter 1.45 (literal floating point
value).
martin