2017-12-07 12:42:55

hi all:
i have a question in bgt, take this example:

class enemy
int speed;
enemy(int speed) {
this.speed = speed;
void add_enemy([email protected] entry) {
//here my question goes
//what is the diference between
@board[5] = @entry;
@board[5] = entry;

the two codes are working well for me as the same.


Thumbs up

2017-12-07 13:14:38

I'm not sure if there's a difference. I generally use the @ on both sides only when comparing (ex, if(@[email protected]).). I think BGT tries to make the right side match the left—you'll notice that the compiler gives a warning instead of an error if you type if(@a==b).
The two cases where it's most important are the first side of an assignment (otherwise it will look for an opAssign method), and in dictionaries (if you don't use the @ when storing an object like this in a dictionary, you'll get a null pointer Runtime error).
But, I'm not sure if there's a difference between @a=b, and @[email protected]

Some of my games
Keep up to date by following @Jeqofire on twitter!
Ear Ninja?

Thumbs up