Re: Ruby - Persistent local variables
Posted: Fri Sep 26, 2014 4:27 pm
the array should be persistent with that code. I recommend putting this in the beginning of the code, so the array is initialized on startup:Perfect Human Interface wrote:Can you give me an example of that in syntax?
For example say I want to do this (just random):and I want @Array to be persistent.Code: Select all
for i in 0...(@Array.length-1) if @Array[i] == @input @Array[i] = 0; end end
Code: Select all
def init
@Array=[0] #array with only one element. even empty array might do the trick
end