I have a record type Foo which is an open record, with a set of defined fields. I have another record Bar which is also an open record, with a set of defined fields. I need to map data from Foo to Bar like this:
type Foo record {
string fs;
int fi;
};
type Bar record {
string bs;
int bi;
};
function transform (Foo foo) returns Bar => {
bs: foo.fs,
bi: foo.fi
}
How can I map the rest fields from Foo to Bar? I don't need to change the rest field names, but to map them as it is.
Can't think of a direct syntax. You could do something like this though.
transform()function would look like this.