Reputation: 585
Here is a class Card and a 2d array aGrid.
The 2d array aGrid is set to aGrid = new Card[4,4]; it looks like I am making it an instance of the Card class and an array at the same time. How does this work??
I thought a variable could only be set to one type of thing ---> an object instance or an array but not both.
Here is the code:
class Card extends System.Object {
var isFace:boolean = false;
var isMatched:boolean = false;
}
var aGrid:Card[,];//2d array to keep track of the shuffled, dealt cards
var aGrid = new Card[4,4];
Upvotes: 0
Views: 127
Reputation: 14171
You are assigning to aGrid an array of Cards, not a single card.
You should probably call:
aGrid = new Card[4,4];
If you were to call:
aGrid = new Card();
then it would assing a Card instance to aGrid.
Upvotes: 1