Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Closures in Swift First Class Functions Higher Order Functions

"Make sure removeVowels accepts a string and returns a string" Code works in playground but won't run in coding window?

Output.html is blank, code works in playground, doesn't seem to work on the site, any ideas?

functions.swift
// Enter your code below

extension String {

  func transform(_ operation: (String) -> String) -> String {
     return operation(self)
  }

func removeVowels(from value: String) -> String {
      let vowels = ["a", "A", "e", "E", "i", "I", "o", "O", "u", "U"]

    return String(value.characters.filter { !vowels.contains("\($0)") })
}

}

1 Answer

Jhoan Arango
Jhoan Arango
14,575 Points

Hello,

Just put the function outside of the "String" extension. Right now is a method, it should be a function. A function does not belong to a type, a method is a function that belongs in a type such as class or struct.

Give it a try.