any better ideas for this code? I basically have t...
# announcements
d
any better ideas for this code? I basically have two collections that need to be matched by a given criteria while each element can only be used once.
Copy code
val results = giftCards.associate { giftcard ->
            val orderItem = orderItemsLeft.first { giftcard.value.amount == it.price }
            orderItemsLeft = orderItemsLeft.filter { it != orderItem }

            orderItem.id to OrderItemGiftCard(orderItem.id, giftcard.id, giftcard.createdAt)
        }