Skip to content

Instantly share code, notes, and snippets.

View mushu8's full-sized avatar

Alexandre Sagette mushu8

View GitHub Profile
@mushu8
mushu8 / isNilOrEmpty.swift
Last active August 29, 2015 14:27 — forked from kristopherjohnson/isNilOrEmpty.swift
Swift: determine whether optional String, NSString, or collection is nil or empty
import Foundation
/**
Determine whether Optional collection is nil or an empty collection
:param: collection Optional collection
:returns: true if collection is nil or if it is an empty collection, false otherwise
*/
public func isNilOrEmpty<C: CollectionType>(collection: C?) -> C? {
switch collection {