Hi
I was testing some sample code on structs:
Why is it I get the error above when I try to refer to tg.n1?
As I read the documentation it should be doable
Using liststruct I can see that the structure has values.
I've tried moving "struct twopart scalar tg" around in the code without luck. It seems like it is unnecessary.
I was testing some sample code on structs:
Code:
: mata clear
:
: struct twopart {
> real scalar n1, n2
> }
:
: struct twopart scalar new_twopart(val)
> {
> struct twopart scalar t
> t.n1 = 1
> t.n2 = val
> return(t)
> }
:
: struct twopart scalar tg
nothing found where '(' expected
r(3000);
: tg=new_twopart(5)
: liststruct(tg)
1 structure of 2 elements
1.1 1 x 1 real = 1
1.2 1 x 1 real = 5
: tg.n1
type mismatch: exp.exp: transmorphic found where struct expected
r(3000);
: end
As I read the documentation it should be doable
Using liststruct I can see that the structure has values.
I've tried moving "struct twopart scalar tg" around in the code without luck. It seems like it is unnecessary.

Comment