是withD语言的经典块吗?
我正在寻找以下行为:
struct Address {
string street;
int number;
}
struct Person {
Address address;
}
// in some function
Person p = ...
with(p.address) {
street = "Wide St.";
number = 123;
}
// I am open to other solutions, if they could work e.g.
p.address.with => { street = ...; number = ...; }
assert(p.address.street == "Wide St.");
Run Code Online (Sandbox Code Playgroud)
如果它不可用,您将如何更新嵌套结构的几个字段?在C++中,我将嵌套分配给引用.