Skip to content

Instantly share code, notes, and snippets.

@dnedrow
Last active March 16, 2020 12:25
Show Gist options
  • Select an option

  • Save dnedrow/02c2dd102d36b758aee986b8dcd018ef to your computer and use it in GitHub Desktop.

Select an option

Save dnedrow/02c2dd102d36b758aee986b8dcd018ef to your computer and use it in GitHub Desktop.
Example of using a block to set a variable in Swift.
self.fitLabel.isHidden = { (message: String?) -> Bool in
guard let thisMessage = message else {
return true
}
self.fitLabel.text = thisMessage
self.fitLabel.textAlignment = self.traitCollection.horizontalSizeClass == .regular ? .right : .left
return false
}(vm.fitInfo?.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment