Skip to content

Instantly share code, notes, and snippets.

@achernoprudov
Last active July 27, 2021 12:01
Show Gist options
  • Save achernoprudov/e7a04026e7b106bb5d1dcec9410e3c88 to your computer and use it in GitHub Desktop.
Save achernoprudov/e7a04026e7b106bb5d1dcec9410e3c88 to your computer and use it in GitHub Desktop.
@resultBuilder
enum MenuElementsBuilder {
static func buildExpression(_ element: UIMenuElement) -> [UIMenuElement] {
return [element]
}
static func buildBlock(_ elements: [UIMenuElement]...) -> [UIMenuElement] {
return elements.flatMap { $0 }
}
static func buildOptional(_ component: [UIMenuElement]?) -> [UIMenuElement] {
return component ?? []
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment