How to define a variable value using operator==

I just want define variable M2_ca=1 if Mc2[i,j]=m, how could i code in rstan?

M2_ca[i,j]=operator==(Mc2[i,j],m);

Where did you come across this syntax? In 20yrs of coding I’ve never seen anything like that.

Stan Functions Reference, probably.

I guess you’ve never had to deal with C++

Anyway, the operator keyword is just a weird way to write it as if it were a function signature. The correct way to write Stan code is

M2_ca[i,j] = (Mc2[i,j] == m);
3 Likes

A bit, but clearly not enough to encounter this!