Skip to content

Instantly share code, notes, and snippets.

View vicc's full-sized avatar

Vicc Alexander vicc

View GitHub Profile
@vicc
vicc / string-truncate.swift
Last active May 4, 2020 02:33 — forked from jesskturner/string-truncate.swift
A little truncate function extension for the default String type (Swift 3 Ready)
extension String {
/**
Truncates the string to the specified length number of characters and appends an optional trailing string if longer.
- Parameter length: A `String`.
- Parameter trailing: A `String` that will be appended after the truncation.
- Returns: A `String` object.
*/
func truncate(length: Int, trailing: String = "…") -> String {