Search Your Question

Write a program to define closure which accepts string and return integer.

 Write a closure that accepts string and return length of string(which is integer) :


let simpleClosure:(String) -> (Int) = { name in 

    return name.count

}

let result = simpleClosure("Hello World")

print(result)

No comments:

Post a Comment

Thanks