Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array and Dictionary.values is missing forEach-method #11

Open
weyert opened this issue Apr 23, 2019 · 0 comments
Open

Array and Dictionary.values is missing forEach-method #11

weyert opened this issue Apr 23, 2019 · 0 comments

Comments

@weyert
Copy link

weyert commented Apr 23, 2019

I would like to implement the forEach-method (see: https://developer.apple.com/documentation/swift/dictionary/values/2894113-foreach) and I was wondering what the best approach is to do.

I am not sure what the best approach would to implement this? Can I import SwiftBaseLibrary in my own projects (e.g. SharedProject) and then leverage it and make my own changes and then make pull requests for them?

The library is suggesting that it's available through Sequence:

public func forEach(@noescape body: (T) throws -> ()) rethrows {

but I am not getting it working when I do something like:

typealias LocationNode = TreeNode<Location>
var availableRootNodes = [TreeNode<Location>]()

// Code that populates the above array
for node in dictionary.Values {
   availableRootNodes.append(node)
}

// Attempt to iterate through the list
availableRootNodes.forEach { (value) in
   NSLog("Item has been discovered")
}

If I try to compile code like above I am getting the error:

E: No member "forEach " on type "Array<TreeNode<Location>!>" [/Users/weyertdeboer/Development/Projects/x/x/version-3/config-app/SharedProject/LocationService.swift (161)]

This was referenced May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant