Ralph Macalino Ralph Macalino - 3 months ago 46
Swift Question

Swift 3 Set Operations Subtract

var studSubj: [String: Set<String>] = [

"Juan":["OOP","WEBAPP","MOBILEAPP","XML"],

"Pedro":["XML","DATASTRUCT","OOP","WEBAPP"],

"Jose":["WEBAPP","XML","SYSAD"]];

print(studSubj["Juan"]!.subtract(studSubj["Pedro"]!));


I'm using IBM Swift Sandbox to simulate the code. The only output i see is (), is there anything wrong with my code?

[EDIT]
I am subtracting to get the unique subjects taken by juan.

ddb ddb
Answer

try this

print(studSubj["Juan"]!.subtracting(studSubj["Pedro"]!));