iOS Closures in Swift First Class Functions Higher Order Functions

Aananya Vyas
Aananya Vyas
20,157 Points

it says : Your code could not be compiled. Please click on "Preview" to view the compiler errors. and I cant figure out

i'm confused

functions.swift
extension String {

    func transform(_ arguement:(String) -> String) -> String {

        return arguement(self)

    }

func removeVowels(from value: (String)-> String) -> String {
  var output = ""
        for char in value.characters {

            if !(char == "a" || char == "A" || char == "e" || char == "E" || char == "I" || char == "i" || char == "o" || char == "O" || char == "u" || char == "U") {
                output.append(char)
            }
        }
        return output

    }
}

1 Answer

Heidi Puk Hermann
Heidi Puk Hermann
32,184 Points

Almost there! The issue is when you define your function

func removeVowels(from value: (String)-> String) -> String {

you set the variable as a closure, but it should just be a simple string; should look like the following...

func removeVowels(from value: String) -> String {

The rest of your code works fine :)