dart - 如何将 Dart 中的命名参数传递给另一个班级讲师?
问题描述
例如我有一个用户类
class User {
String name;
String address;
String weaponId;
String weaponMerchant;
Date weaponExpiration;
Weapon weapon;
User({this.name, this.address, this.weaponId, this.weaponMerchant, this.weaponExpiration}) {
weapon = new Weapon(weaponId: weaponId, weaponMerchant: weaponMerchant, weaponExpiration: weaponExpiration);
}
}
class Weapon {
String id;
Weapon({this.id, this.weaponId, this.weaponMerchant, this.weaponExpiration});
}
飞镖中有什么方法可以使用扩展运算符或任何东西,这样我就不需要一个一个地传递这些属性?
weapon = new Weapon(weaponId: weaponId, weaponMerchant: weaponMerchant, weaponExpiration: weaponExpiration);
解决方案
推荐阅读
- powershell - Powershell 文件列表删除项目检查是否失败
- python - How can I swap values in PyTorch Tensor?
- r - 如何绘制 2 天小时刻度(从 0 到 23 并从 0 到 23 重新开始)?
- vue.js - echarts - 将具有相同值的轴标签分组
- java - 在 Java 中没有出现 stackoverflow 错误的参数传递
- reactjs - 单击提交按钮时可以跳过 Ant Design 表单验证吗?
- jdbc - kafka 源连接器不填充主题
- .htaccess - 我通过 .htaccess 从 http 到 https 的重定向不起作用。我在这里阅读了许多帖子,但我无法弄清楚我的错误在哪里
- c++ - 如果是静态的,则POD默认初始化,如果是自动的,则为构造函数?
- java - 如果用Java接收数据,如何制作从服务器接收数据并将数据发送到服务器的程序