0

I couldn't understand the syntax of below code in SwiftUI. It is creating a VStack and last argument is a closure(ViewBuilder). But how does the closure return two Text. Are they a tuple or a array or anything else?

VStack{
    Text("Hello, world!")
    Text("Hello, world again!")
}
Guoping Zhang
  • 71
  • 2
  • 16
  • ViewBuilder uses a concept called Result builders (formerly known as function builders). The compiler translates this code by calling a function and passing all the all the unassigned objects as parameters to that function. Now that function could do what ever it wants to do. There is a talk about this Apple developer videos. – user1046037 Jan 02 '21 at 04:27
  • In this case both the instances of Text are passed as parameters to a function which does something with it – user1046037 Jan 02 '21 at 04:28

0 Answers0