jweinst1
2/21/2016 - 12:13 AM

struct that collects words in swift

struct that collects words in swift

//initialized via declared variables,
//collects words
struct collector {
    var bin:[String]
    mutating func collect( input:String) ->Void {
        let words = input.componentsSeparatedByString(" ")
        for elem in words {
            self.bin.append(elem)
        }
    }
    func getwords() ->[String] {
        return self.bin
    }
}