Answer the question
In order to leave comments, you need to log in
How to implement such (example in the full message) code writing in Swift?
Good afternoon. Could you please tell me how this syntax is implemented?
let html = scopes {
html {
body {
h1 { inner = "hello" }
}
}
}
public typealias Closure = (Void) -> Void
public func body(_ c: Closure) {
print(c)
}
let bo = body {
text = "test"
}
Answer the question
In order to leave comments, you need to log in
It's called Trailing Closures.
Well, actually you did it. Then just call another function inside your closure.
An example with your implementation:
public func body(_ c: () -> Void) {
print(c)
}
body {
body {
// second lvl
}
text = "test"
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question