I'm currently updating some Swift 2.2 code to Swift 3.0. I had some
Overloaded Operators that needed converting. I've managed to get my code to
compile and run. Although, looking to the community for any constructive
criticism on my approach.
Regards
import UIKit
import Foundation
func lines(input:String) -> [String] {
return input.components(separatedBy: NSCharacterSet.newlines)
}
func getContents(text:String) -> String {
let a = text.components(separatedBy: ".")
var temp = ""
for (_,element) in a.enumerated(){
temp = "Value: \(temp) \(element) \n"
}
return temp
}
precedencegroup FunctionalCompostion {
associativity:left
}
infix operator <<< : FunctionalCompostion
func <<< <A,B,C> (g: @escaping (B) -> C, f: @escaping (A) -> B) -> (A) ->
C {
return { x in g(f(x)) }
}
let functionalWay = lines <<< getContents
functionalWay("K.w.a.m.e").count