So I've been playing around with Swift 3 on playground and am just trying to convert some data analysis stuff I wrote in python (as an exercise in language difference, etc.) For some reason my for in loop isn't following through with appending the "userArr" arrays with the names from "users".
for (key, value) in friendships{
userArr[key].append(users[value]!)
userArr[value].append(users[key]!)
}
When I delete the .append(arg) I'm able to obtain correct references to each item I'm trying to find (and append), and the playground margin marks that the loop occurred 16 times. But for some reason the second I add the member function playground doesn't even say the for-in loop occurred once.
To be clear, the arrays I'm trying to populate are not being appended as they should be.
Is this a language specific issue with using member-functions in a for in loop? The Arrays and Dictionaries I'm referencing in the loop are printed below:
let users = [
0 : "Jiro",
1 : "Dunn",
2 : "Lou",
3 : "Bri",
4 : "Thor",
5 : "Clive",
6 : "Rix",
7 : "Devin"
]
let friendships = [ (0,1), (0,3), (1,7), (1,2),
(2,5), (2,7), (3,2),
(3,5), (4, 1), (4,6),
(5,4), (5,1), (6,7),
(6,2), (7,4), (7,0) ]
var Jiro: Array<String> = [], Dunn: Array<String> = [], Lou: Array<String> = [], Bri: Array<String> = [],
Thor: Array<String> = [], Clive: Array<String> = [], Rix: Array<String> = [], Devin: Array<String> = []
var userArr = [Jiro, Dunn, Lou, Bri, Thor, Clive, Rix, Devin]
Given that other users were able to run this code successfully, I'll close this as an issue with playground