Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Case 1:
- let indexText = atIndex != nil ? "-\(atIndex!)" : ""
- // Case 2:
- let myArray = someObject != nil ? [someObject!] : []
- // Longer solution
- var myArray = []
- if let obj = someObject {
- myArray = [obj]
- }
- // Other similar cases :)
- let myPrice: GraphQL.PriceInput? = price != nil ? GraphQL.PriceInput(amount: price!.amount, currency: price!.currency) : nil
- // ------------------------------------
- let width = ad.width != nil ? R.string.localizable.ad_details_attr_measurement_centimetres(Double(ad.width!)) : nil
- // ------------------------------------
- return intValue != nil ? String(intValue!) : nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement