Just ordered the 2nd Edition (good old Amazon)...
Woohoo!
SM
···
-----Original Message-----
From: Gennady Bystritksy [mailto:gfb@tonesoft.com]
Sent: 13 April 2005 21:04
To: ruby-talk ML
Subject: Re: newbie question re: variable assignment
Simon.Mullis@equinoxsolutions.com wrote:
This is it... Many thanks.
1.upto(9) { |x| puts "#{x}"[0] }
I was missing the literal form v. method info.
Just so I know -- Where would I look to find this info? Rdoc? ri?
Pickaxe ("Programming Ruby" by Dave Thomas and Andy Hunt).
Thanks again.
SM
...It's all getting a little bit clearer...
-----Original Message-----
From: Trans [mailto:transfire@gmail.com]
Sent: 13 April 2005 19:15
To: ruby-talk ML
Subject: Re: newbie question re: variable assignmentHi--
Dont; worry this is a low bite boardWhy doesn't this work?
1.upto(9) do |x|
puts ?#{x}
endWell, its cuz you're trying to do string interpolation directly into
ruby code, which can't be done. The interpolation (i.e. #{x}) only
works in strings. Secondly, the ? is a literal form and not a method,
so you can;t pass it arguments. To get the ascii value of a string use
str[n] where n is the index of the character you wish to convert, in
this case 0.1.upto(9) do |x|
puts "#{x}"[0]
endBTW, I believe this will change in future verions of Ruby since Ruby
will be gaining more advanced encoding. So instead there will be a
specific method, like String#ascii(n), or something, to do this.
[Correct me if I am misinformed all.] But for now the above is the
way.T.
----------------------------------------------------------------------
--------------------
Equinox Converged Solutions
Tel: +44 (0)1252 405 600
http://www.equinoxsolutions.com
Equinox Converged Solutions is a trading name of Synetrix Holdings
Limited.
IMPORTANT NOTICE:
This message is intended solely for the use of the Individual or
organisation to whom it is addressed. It may contain privileged or
confidential information. If you have received this message in error,
please notify the originator immediately. If you are not the intended
recipient, you should not use, copy, alter, or disclose the contents of
this message. All information or opinions expressed in this message
and/or any attachments are those of the author and are not necessarily
those of Synetrix Holdings Limited. Synetrix Holdings Limited accepts no
responsibility for loss or damage arising from its use, including
damage from virus.
------------------------------------------------------------------------
-------------------
------------------------------------------------------------------------------------------
Equinox Converged Solutions
Tel: +44 (0)1252 405 600
http://www.equinoxsolutions.com
Equinox Converged Solutions is a trading name of Synetrix Holdings Limited.
IMPORTANT NOTICE:
This message is intended solely for the use of the Individual or organisation to whom it is addressed. It may contain privileged or confidential information. If you have received this message in error, please notify the originator immediately.
If you are not the intended recipient, you should not use, copy, alter, or disclose the contents of this message. All information or opinions expressed in this message and/or any attachments are those of the author and are not necessarily those of Synetrix Holdings Limited.
Synetrix Holdings Limited accepts no responsibility for loss or damage arising from its use, including damage from virus.
-------------------------------------------------------------------------------------------