If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby - Persistent local variables
11 posts
• Page 2 of 2 • 1, 2
Re: Ruby - Persistent local variables
Perfect Human Interface wrote:Can you give me an example of that in syntax?
For example say I want to do this (just random):
- Code: Select all
for i in 0...(@Array.length-1)
if @Array[i] == @input
@Array[i] = 0;
end
end
and I want @Array to be persistent.
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:
- Code: Select all
def init
@Array=[0] #array with only one element. even empty array might do the trick
end
Also look at the savestate and loadstate methods in manual.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
11 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 65 guests