Assuming you have a non-standard Input.repeat? method which gets the key press according to... it's
Virtual-Key Code?... it looks ok (ugly due to lack of proper indention though)
I would suggest changing the range to 65..90 as ForeverZero suggest and use the .chr method. Here is an example which hopefully can help you on your way:
str = ''
for i in 65..90
str += i.chr
end
print str
@ForeverZero:
It definitely does not do the same thing.
Using a literal array is a good idea as you get a tighter and easier to read code.
Note that %w does not interpolate while %W does so using capital W would be a functional equivalent. As interpolation is not required %w is a better choice.
Syntax wise parentheses () are used for the array rather than brackets {} and no spaces must be between %w and (.
Fixing the literal array syntax problems the snippet can look like this:
a = %w( a b c d e f g h i j k l m n o p q r s t u v w x y z )
(65..90).each {|i| @my_variable += a[i] if Input.repeat?(i) }
A word of advice is to always test run code snippets before presenting them as you'll find errors such as these which you can be fixed easily and quickly while they may cause more costly confusion for the people you are trying to help.
The second line is more troublesome because the logic rather than the syntax is wrong. Variable
g had a purpose because the number check for in Input.repeat? is different from the index. Maybe adding
nil will give an error, maybe it won't. That depends on the type @my_variable is.
*hugs*