On 6/9/25 12:24 AM, confuzzled wrote:

> Is it possible to accomplish the following using ref instead of
> pointers?

Your example is a good case for a pointer. Was there a reason why a reference should be used?

Having said that, you can even drop the pointer and use a DataSource as-is:

struct Engine
{
    DataSource dataSource;
    // ...
}

However, that would be preferable only if DataSource did not have a static array but I assume you wrote int[3] just as an example. Otherwise:

struct DataSource
{
    int[] data;    // <-- Now a slice
}

That works because DataSource.data is a *reference* to your external data.

Ali

Reply via email to