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

Please help me with a function in Swift.It shows 5 errors in Xcode. I have 3 days trying to figure it out.Plz

it shows 5 errors at this part of code:

func randomFact () -> String {
  let unsignedArrayCount  = UInt32(factsArray.count)
        func randomFact() -> String {
return factsArray[Int((arc4random_uniform(unsignedArrayCount))]
        }

1) Expected ',' separator
2)Expected expression in a list of expressions
3)Expected ')' in an expression list
4)Expected expression in a list of expressions
5)Expected ']' in an expression list

// This is the entire code

import Foundation

struct FactBook {
    let factsArray = [
        "Ckemi",
        "Ky eshte nje aplikacion i bere ne gjuhen programuese Swift.",
        "Gjuha programuese Swift eshte nje gjuhe moderne,fleksibel dhe e sigurt.",
        "Ajo u krijua nga kompania Apple ne vitin 2014 ",
        "Ky aplikacion ka si qellim te nxise dhe te promovoje kulturen e qyteteve te Shqiperise",
        "Ky projekt eshte konceptuar te vihet ne pune nga Bashkite dhe zonat e tyre perkatese"

    ]

    func randomFact () -> String {

        let unsignedArrayCount  = UInt32(factsArray.count)
        func randomFact() -> String {
return factsArray[Int((arc4random_uniform(unsignedArrayCount))]
        }


    }
}

Moderator Edited: Added markdown to the question so the code can more easily be read.

Your function doesn't look right, try retyping the block of code into one function instead of nesting a function within a function.