Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Inconsistency between irb and Win7 cmd

Reply
Thread Tools

Inconsistency between irb and Win7 cmd

 
 
William Knapp
Guest
Posts: n/a
 
      05-23-2011
I'm trying to print a string created from the contents of two arrays.

label = ""
for i in 1..vArr.length-2
label = "#{label}#{vArr[i]}#{dArr[i]}"
end
print label

vArr is an array of letters and dArr is an array of integers.
The label should interweave the two.

When I run the code from irb the resulting string is: T0S6S50Q0
When I run the code as part of a .rb file from the command prompt in
Win7, I get: 8408368350810

In the latter, all letters have been converted to their integer
representations.
T=84
S=83
Q=81

I would like to run the .rb file from cmd and get the string I'm getting
in irb.

Any help is welcomed. Thanks.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Ryan Davis
Guest
Posts: n/a
 
      05-23-2011
[Note: parts of this message were removed to make it a legal post.]


On May 23, 2011, at 5:09, William Knapp <> wrote:

> vArr is an array of letters and dArr is an array of integers.
> The label should interweave the two.
>
> When I run the code from irb the resulting string is: T0S6S50Q0
> When I run the code as part of a .rb file from the command prompt in
> Win7, I get: 8408368350810


Sounds like a pathing issue and you're running 1.8 via cmd and 1.9 for irb.

?a in 1.8 is the ASCII code for 'a'.

?a in 1.9 is 'a'.

Try %w[a b c]. It works the same in both.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby's inconsistency or an IRB issue ? David Unric Ruby 4 11-18-2010 03:35 PM
Win7 Pro x64 dies with BSOD on my toshiba laptop (Win7 Retail/RTM) Warren Postma Windows 64bit 6 11-20-2009 11:23 PM
[exec cmd for cmd in cmds] =?ISO-8859-1?Q?Sch=FCle_Daniel?= Python 3 03-08-2006 03:21 PM
Interpreter-like help in cmd.Cmd Sarir Khamsi Python 4 06-26-2005 06:57 PM
read input for cmd.Cmd from file Achim Domma (Procoders) Python 2 06-03-2005 08:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57