what's the proper way to assign this?

Dr Machine Code jckj33 at gmail.com
Tue Jan 4 17:23:11 UTC 2022


I've tried to build 2 years old D project and I was getting the 
error:

  > Error: cannot append type `Nullable!(SelectorEntry)` to type 
`SelectorEntry[]`

I went to use Nullable, 'cause I've never used it before. Boiling 
down the error was something like (minimal code reproduction):

```d
    	auto e = Entry("Bill", 30);
    	auto entry = nullable(e);
	Entries data;
	data.entries ~= entry;


struct Entry
{
	string name;
	int id;
}

struct Entries
{
	Entry[] entries;
	int lid;
}
```

I could fix just with

```d
	data.entries ~= entry.get;
```

taking away all the nullables. My question is: should I use .get 
directly or there's a "proper way" to do it, maybe keeping the 
nullable? I'm asking so I don't create a misbehavior in the 
application.


More information about the Digitalmars-d-learn mailing list