I am totally new with Swift...
now I am with the structs... with computed properties...
struct Code {
var language: String
var containsErrors = false
var report: String {
if containsErrors {
return "This \(language) code has bugs!"
} else {
return "This looks good to me."
}
}
}
I can't understand why I have to write "return" in this code... why for example not using "print" instead if I want it to be printed?
if i try with
if containsErrors {
print (...)
}
it says it must return something... I don't understand why...
the computed property is:
var report: String {...}
where does it say it must return a String ??? the { } in a computed property always mean return ????
doesn't is just say that it must be a string? it doesn't matter if it is printed, or returned,...????
Sorry if it is an obvious question... just starting with all of this...
To return something in a function you must write ->
How do I know that it must return something in a computed property ?
Sorry if my english is not very good, because it is not my first language...
Anyway, I will finish my 100 days of switfUi courseeeee!!!!