Can somebody explain this to me,
I have a type like so;
public type MemberWithProfile = {
member: User.User;
profile: Profile.Profile;
};
in the function i have a empty list;
var membersWithProfiles: List.List<Response.MemberWithProfile> = List.nil();
When iterating over the Array
with values to fill up the membersWithProfiles
list;
var usersList = Trie.toArray<Principal, User.User, ()>(users, func (k, v) {
var profile = ProfileHelper.getProfileByPrincipal(k, profiles);
switch(profile) {
case(null) {
return;
};
case(?profile) {
var memberWithProfile: Response.MemberWithProfile = {
member = v;
profile = profile;
};
membersWithProfiles := List.push(memberWithProfile, membersWithProfiles) ;
};
}
Everything works fine and i get the candid code as;
export interface MemberWithProfile { 'member' : User, 'profile' : Profile }
export type MemberWithProfileResponse = { 'ok' : Array<MemberWithProfile> } | { 'err' : Error };
But when i change the properties of MemberWithProfileResponse
to be nullable like so (and change the iterate function accordingly by prefixing the values with a ?
);
public type MemberWithProfile = {
member: ?User.User;
profile: ?Profile.Profile;
};
I get this candid code? (the member and profile are both an array)?
export interface MemberWithProfile {
'member' : [] | [User],
'profile' : [] | [Profile],
}
export type MemberWithProfileResponse = { 'ok' : Array<MemberWithProfile> } |
{ 'err' : Error };
Is there some explanation to this or is it a bug?