In Matlab, I recall being able to declare an array and initialize it and it resides in memory during the entire Matlab session. I could copy it, modify it, and run it through tests. Is this option available in Ruby? Basically I want to create and populate an array of 12 million 32-bit integers. Then I want to run code that accesses that memory. I don’t want to have to re-initialize that array every time I tweak/debug my ruby code.
Share
The global variable is one way but a bit cumbersome I’d say.
That means you want persistence of objects as you want it to be available across modifications of your code. You then need to initialize your data and save it in a file. You have several possibilities, something like YAML/JSON or, in a binary but more efficient way, Marshalling.
If you have a data structure, you can save it in YAML with this
JSON is pretty much the same. Using Marshal.dump is equivalent.
Then you can have a method in your code that read in the data.