[swift-users] Why can I not filter or map a dictionary to another dictionary?

Vincent O'Sullivan vjosullivan at hotmail.com
Thu Oct 27 01:43:53 CDT 2016


Ah.  Having seen the other answers, I can now see the implied question.

On 27/10/2016, 07:39, "Vincent O'Sullivan via swift-users" <swift-users-bounces at swift.org on behalf of swift-users at swift.org> wrote:

    You can.  You just need to get the syntax right:
    
    let smallerDictionary = bigDictionary.filter { (key, value) in <some test returning Bool> }
    
    let bd = [1:"A", 2:"B", 3:"C"]
    let sd = bd.filter{(k, v) in
        k > 1}
    dump(sd)
    
    On 27/10/2016, 01:12, "Rick Mann via swift-users" <swift-users-bounces at swift.org on behalf of swift-users at swift.org> wrote:
    
        It seems fairly natural to want to do this:
        
        let bigDictionary = ...
        let smallerDictionary = bigDictionary.filter { key, value in <some test returning Bool> }
        
        Similarly, it seems natural to want to map this way.
        
        Am I overlooking something?
        
        -- 
        Rick Mann
        rmann at latencyzero.com
        
        
        _______________________________________________
        swift-users mailing list
        swift-users at swift.org
        https://lists.swift.org/mailman/listinfo/swift-users
        
    
    
    _______________________________________________
    swift-users mailing list
    swift-users at swift.org
    https://lists.swift.org/mailman/listinfo/swift-users
    




More information about the swift-users mailing list