Get the sum of the values of the same label from the struct

Get the sum of the values of the same label from the struct

I need to add the unappeared to the Array from this information. If there is a duplicate, the money will be summed up and then saved into one. How can I achieve this? The data may be a lot.

I need to add the unappeared to the Array from this information. If there is a duplicate, the money will be summed up and then saved into one. How can I achieve this? The data may be a lot.

import UIKit

struct TestData { let Label : String var Money : Double }

var SaveDate = TestData var TestD = TestData SaveDate.append(TestData(Label: "test1", Money: 55)) SaveDate.append(TestData(Label: "test1", Money: 35)) SaveDate.append(TestData(Label: "test2" , Money: 15)) SaveDate.append(TestData(Label: "test1" , Money: 10)) SaveDate.append(TestData(Label: "test3" , Money: 30)) print([{Label "test1", Money 55}, {Label "test1", Money 35}, {Label "test2", Money 15},{Label "test1", Money 10}, {Label "test3", Money 30}])

//Result presentation //Label1 = test1 , Money = 100 //Label2 = test2 , Money = 15 //Label3 = test3 , Money = 30


arrays swift

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Dedicated Swift Developers

Want to create a native iOS application for your Startup? **[Hire Dedicated Swift Developers](https://hourlydeveloper.io/hire-dedicated-swift-developer/ "Hire Dedicated Swift Developers")** for end-to-end services like development, migration...

Mastering Swift: Tips About Array and Dictionary Literals

How to use Swift literals to initialize the 3 fundamental collection types: array, set and dictionary. Details about collection type inference.

Grouping Array Elements With Dictionary in Swift

In Swift 5, Apple introduced a “grouping by” dictionary initializer. According to the documentation, the initializer has a definition of: Creates a new dictionary whose keys are the groupings returned by the given closure and whose values are arrays of the elements that returned each key.

Swift: constraining protocol extensions

Constraining Element to Equatable means that this method is only available on arrays with Equatable elements. extension Array where Element

NumPy Array Tutorial - Python NumPy Array Operations and Methods

Learn about NumPy Array, NumPy Array creation, various array functions, array indexing & Slicing, array operations, methods and dimensions,It also includes array splitting, reshaping, and joining of arrays. Even the other external libraries in Python relate to NumPy arrays.