Access outer member of struct from inner struct

Jacob Carlborg doob at me.com
Tue Apr 2 18:52:07 UTC 2019


On 2019-04-02 20:44, Q. Schroll wrote:

> After removing the calls to writeln, the error I get is:
> 
>> `this` for `read` needs to be type `Outer` not type `Inner`
> 
> You cannot access stuff in Outer because Inner objects are not outer 
> objects and don't implicitly own an Outer object. In your Inner method 
> `write`, there is no Outer object present at all to call the method on.

It works if the struct is nested inside a function [1]. I thought it 
would work nested inside a struct too.

[1] https://dlang.org/spec/struct.html#nested

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list