Hi. When tested in Playfround, Apple's own code, from it's own documentation (from Swift 4.2 & 5 book), seems to produce errors.
How can it be corrected, if it's an invalid code (that got published somehow):
func greetAgain(person: String) -> String {
return "Hello again, " + person + "!"
}
print(greetAgain(person: "Anna"))
func greet(person: String, alreadyGreeted: Bool) -> String {
if alreadyGreeted {
return greetAgain(person: person)
} else {
return greet(person: person)
}
}
print(greet(person: "Tim", alreadyGreeted: true))
Also, how can the this block of code (or is this called a code snippet? What's the difference, by the way?) be fixed, if the arguments/input value, 'alreadyGreeted' is changed to 'false' in line 14?
Thank you.
God bless, Proverbs 31
Advanced happy Easter ✟🐰 (see you all in heaven & the heaven of all programming languages: Swift:-)