Skip to content

Commit a65f56f

Browse files
committed
feat: prepend & append
1 parent c89637a commit a65f56f

File tree

1 file changed

+14
-0
lines changed
  • app/src/main/java/moe/matsuri/nb4a/utils

1 file changed

+14
-0
lines changed

Diff for: app/src/main/java/moe/matsuri/nb4a/utils/Util.kt

+14
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ object Util {
122122
val currentMap = (to[k] as Map<*, *>).toMutableMap()
123123
currentMap += v
124124
to[k] = currentMap
125+
} else if (v is List<*>) {
126+
if (k.startsWith("+")) { // prepend
127+
val dstKey = k.removePrefix("+")
128+
var currentList = (to[dstKey] as List<*>).toMutableList()
129+
currentList = (v + currentList).toMutableList()
130+
to[dstKey] = currentList
131+
} else if (k.endsWith("+")) { // append
132+
val dstKey = k.removeSuffix("+")
133+
var currentList = (to[dstKey] as List<*>).toMutableList()
134+
currentList = (currentList + v).toMutableList()
135+
to[dstKey] = currentList
136+
} else {
137+
to[k] = v
138+
}
125139
} else {
126140
to[k] = v
127141
}

0 commit comments

Comments
 (0)