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(enemy@ entry) {
//here my question goes
//what is the diference between
@board[5] = @entry;
//and
@board[5] = entry;
}

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

thanks

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(@a==@b).). 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 @a=@b.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.