How to create an Array of objects like the below C++ example?
What's the Ruby way of doing Print print[1000];?
The below code is C++. I'm just wondering if Ruby has an option to instantiate 1000 unique objects of a class:
class Print
{
public:
Print()
{
static int count = 0;
cout<<"h"<<++count<<endl;
}
};
int main()
{
Print print[1000];
getchar();
return 0;
}
C++? Interesting if its notcountis a global variable and the output looks like: "h0 h1 h2 h3 "... ?C++, notRuby. You are looking at the wrong code if itsRubyyou want to work with