Forked from JessyCatterwaul/wrapping-and-indentation-opinions.swift
Created
December 20, 2015 05:53
-
-
Save onmyway133/f528306c3c530920e84b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum StringPaddingStyle {case Left, Right} | |
| func padStringToLength( | |
| sourceString: String, | |
| destinationCount: Int, | |
| paddingStyle: StringPaddingStyle = .Left, | |
| paddingCharacter: Character = " " | |
| ) -> String { | |
| let padCount = destinationCount - sourceString.characters.count, | |
| padString = String(count: padCount, repeatedValue: paddingCharacter) | |
| return paddingStyle == .Left ? padString + sourceString | |
| : sourceString + padString | |
| } | |
| func elongatedToShowRationaleForShortcuts( | |
| sourceString: String, | |
| destinationCount: Int, | |
| paddingStyle: StringPaddingStyle = .Left, | |
| paddingCharacter: Character = " " | |
| ) -> String { | |
| let standsAlone = "" | |
| let | |
| standsAlone1 = "", | |
| standsAlone2 = "", | |
| standsAlone3 = "" | |
| let isUsedAgainInThisList = "", | |
| reliesOnIsUsedInThisList = isUsedAgainInThisList, | |
| andThisAlsoRelies = isUsedAgainInThisList | |
| let padCount = destinationCount - sourceString.characters.count, | |
| padString = String(count: padCount, repeatedValue: paddingCharacter) | |
| return { | |
| if paddingStyle == .Left {return padString + sourceString} | |
| else {return sourceString + padString} | |
| }() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment