Global variables

I’m fairly new to Ruby. I typically code in C++. I need a way of initializing a global variable that doesn’t get reset every time I run the code. Like a count for example that isn’t reset to 0 when updating code. I’ve found that by not giving a variable a value initially I get an error for a nil value, although giving it a value makes it always return to that when updating. What are some best practices when it comes to variables that need to retain their values when updating the code?

Take a look at set :slight_smile:

http://sonic-pi.net/tutorial.html#section-10-1

1 Like