Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKenneth Dubroff
10,612 PointsSoccer League Coordinator Project. Stuck on part 2
Hi all, so far, I think I've done well on part 1 of the challenge:
//Arrays of attributes
var playerNames: [String] = ["Jack","John","David","Jasper","Duke","Daisy"]
var height: [Int] = [60, 48, 59, 46, 42, 50]
var prevExp: [Bool] = [true, false, true, false, true, false]
var guardNames: [String] = ["Joseph Smith", "Jane Doe", "John Doe", "Jack Doe", "Billy Bob", "Thor Hammerfist"]
//create dictionary with playerName as Key and playerAttributes as value
var players: [String: [Any]] = [:]
//**Add array data to Dict
var i = 0
//i-1 to match iteration with array position
while i < playerNames.count {
i += 1
players[playerNames[i-1]] = [height[i-1], prevExp[i-1], guardNames[i-1]]
}
//reset i
i = 0
//**
Where I'm getting stuck is trying to create a collection of experienced players. I've tried, an array, dict, and even tuple type (I know, I know...). Each time, I'm getting the same error when trying to loop through the first dictionary and pull the Bool values out. Can't cast Bool as String, or sometimes Int, or... its always a type error. I've gone as far as trying to use .flatMap (again, I know, I know...)
my second dictionary is set up like:
var expPlayers: [String: Bool] = [:]
anyone who can help me will receive 3 gold stars, 4 brownies, and a pat on the back (all in .gif)
Adriano Marcoccia
iOS Development with Swift Techdegree Student 813 PointsAdriano Marcoccia
iOS Development with Swift Techdegree Student 813 PointsDid you ever end up figuring this out?