Hello,
Look at this SwiftUI view:
struct ContentView: View
{
var body: some View
{
Text("Hello !")
}
}
The Text("Hello") line is a closure. Am I wrong ?
There is an implicit return. I can write this:
struct ContentView: View
{
var body: some View
{
return Text("Hello !")
}
}
I can put multiple lines like this:
struct ContentView: View
{
var body: some View
{
Text("Hello !")
Text("Hello2 !")
}
}
I don't understand how works internally the implicit return in this case because we have 2 components.
Also, can you explain me why i can't put a basic swift line code like this:
struct ContentView: View
{
var body: some View
{
Text("Hello !")
print("Hello")
Text("Hello2 !")
}
}
Thanks