Inconsistency between irb and Win7 cmd

W

William Knapp

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}#{dArr}"
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.
 
R

Ryan Davis

[Note: parts of this message were removed to make it a legal post.]


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top