Skip to content

Instantly share code, notes, and snippets.

@plumhead
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plumhead/07ec4be10c5c968304c4 to your computer and use it in GitHub Desktop.
Save plumhead/07ec4be10c5c968304c4 to your computer and use it in GitHub Desktop.
Pipe and Chains!
func getOrElse<S>(f : @auto_closure () -> S)(a : S?) -> S {
if let r = a {
return r
}
else {
return f()
}
}
class func allRootElementsOfType(document : UmlDocument, type : String) -> Array<ModelElementNode> {
return
document.project?.profile?.modelNode?.childNodes
|> getOrElse (Array())
|> filter {$0.elementType == type}
}
class func allStereotypes(document : UmlDocument) -> Array<ModelElementNode> {
return allRootElementsOfType(document, type: "sterotype")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment