Swift Error: Variable used within its own initial value
Solution 1:
You are declaring a constant named word
, and trying to use the argument with the same name to initialize it. The compiler tries to use the just declared constant to assign its own initial value, instead of using the argument.
Solution 2:
I have faced same error when missing out if while unwrapping the text .
By adding if resolved above issue.
Solution 3:
You are redefining a constant word
which has the same name as a parameter within your function
class func buildWordDefinition (word:String, language:Language, root:TBXMLElement) -> WordDefinition
{
// same name as the parameter here
let word = WordDefinition(word: word, language: language)
}
Solution 4:
You have a function parameter called word
in scope and you're trying to create a constant with the same name. Name your constant something other than word
.