Когда я создал заголовок вопроса, я понял, что этот вопрос трудно кому-то правильно передать. Итак, позвольте мне объяснить, пожалуйста.
В основном у меня есть функция, которая требует оператора возврата, в данном случае это Bool. Теперь внутри этой функции. У меня есть другая функция, которая также требует отдельного возврата. Я хочу иметь возможность вызывать оператор возврата для главной / родительской функции внутри Nest.
Код:
func ParentFunction() -> Bool {
// This function represents a real function where you have a to have a return type.
// So in other word you can not take off the fact that you have to have a -> String.
func MyNestedFunction() -> String {
// Here is where you would return the nested functions statement
// but I'd rather not return the string and just end everything and return the Bool from the parent function
return "Hello"
// This is the parent functions return here I want to be able to stop any other process that the ParentFunction might do and just return here.
return true
}
// This is the parent functions return as well.
return true
}
** Больше из актуальный код здесь: **
func MyFunction() -> Bool {
tagger.enumerateTags(in: tagger.string!.startIndex..<tagger.string!.endIndex, unit: .paragraph, scheme: .nameTypeOrLexicalClass) { (tagResult, tokenRange) -> Bool in
if let tag = tagResult, tag == "nil" {
print("Found")
}
return true
}
// I would like it If we have already printed found in the function above then don't continue on to this function below
tagger.enumerateTags(in: tagger.string!.startIndex..<tagger.string!.endIndex, unit: .word, scheme: .nameTypeOrLexicalClass) { (tagResult, tokenRange) -> Bool in
if tagResult != nil {
print("Found")
}
return true
}
return true
}