INSERT GRAPHIC HERE (include hyperlink in image)
Subtitle or Short Description Goes Here
ideally one sentence >
| // Fibonacci series | |
| // F[n] = F[n-1] + F[n-2] | |
| // 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 | |
| // Find the fibonacci number for n interations | |
| func fibonacci(n: Int) { | |
| var num1 = 0 | |
| var num2 = 1 |
| public struct ConditionalArrayFilter <Element> { | |
| let condition: (Element) -> Bool // the condition to meet | |
| private var _array = Array<Element>() | |
| var array: Array<Element> { | |
| get { return _array } | |
| } | |
| init(condition: (Element) -> Bool) { self.condition = condition } | |
| } | |
| private extension ConditionalArrayFilter { |
| // | |
| // Extensions.swift | |
| // | |
| // Created by Valentin Kalchev on 17/11/2015. | |
| // Copyright © 2015 Valentin Kalchev. All rights reserved. | |
| // | |
| import Foundation | |
| extension Array { |
It has been brought to my attention that there was more use for the unintended values() functionality that I had outline in my "Other Languages" Java example below.
On the Swift Evolution mailing list, one developer outlined their requirement to loop through an array of enum case values to add different states to objects.
Another example where a values array would be useful if the developer wants to do something different for each different case, such as setting an image on a UIButton subclass for each different UIControlState
| { | |
| "users": { | |
| "280598f1-e31e-4ced-845e-c8dd10e11ec3": { | |
| "first_name": "Guido", | |
| "last_name": "Marucci Blas", | |
| "username": "guidomb", | |
| "email": "[email protected]" | |
| }, | |
| "280598f1-e31e-4ced-845e-c8dd10e11ad5": { |
| // | |
| // XCTestExtensions.swift | |
| // https://gist.github.com/KoCMoHaBTa/4ba07984d7c95822bc05 | |
| // | |
| // Created by Milen Halachev on 3/18/16. | |
| // Copyright © 2016 Milen Halachev. All rights reserved. | |
| // | |
| import Foundation | |
| import XCTest |
(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)
Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories
Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.
Save that list to some path
The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.
| //: # Swift 3: CGD and URLSessionDataTask | |
| import Foundation | |
| import PlaygroundSupport | |
| //: ### Create background queue | |
| let queue = DispatchQueue.global(qos: .background) | |
| //: ### Computed variable | |
| var time:DispatchTime! { |