【发布时间】:2021-03-22 14:46:02
【问题描述】:
我正在尝试在两个不同的地图(游戏 - 浮动项目)中找到匹配的“关卡”。如何找到这些项目并创建一个键为“级别”且值与浮动项目匹配的新地图?示例代码如下。
List <Game> games = [
{
"id": "Level 1",
"level": 1,
},
{
"id": "Level 2",
"level": 2,
},
{
"id": "Level 3",
"level": 3,
},
];
List <FloatingItem> floatingItems = [
{
"level": "1",
"position": 0
},
{
"level": "1",
"position": 5
},
{
"level": "3",
"position": -5
},
{
"level": "3",
"position": 0
},
{
"level": "2",
"position": 5
},
{
"level": "3",
"position": -5
},
];
【问题讨论】:
-
一定有更好的方法,但 For 循环可以轻松工作。