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
struct Data { | |
var int = 1 | |
mutating func increase(completion: (Int) -> Void) { | |
self.int += 1 | |
completion(self.int) | |
} | |
} |
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
let list = ["Apple", "Boy", "Serval Cat"] | |
func search(for target: String) { | |
for item in list { | |
if item.lowercased().hasSuffix(target.lowercased()) { | |
print("We have a \(item)") | |
return | |
} | |
} |
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
import Foundation | |
protocol BankAccountDelegate: class { | |
func account(_ account: BankAccount, changePasswordTo newPassword: String) throws -> Int | |
func account(_ account: BankAccount, transfer amount: Int, to receiver: Int) throws | |
} | |
//class BankAccount { | |
struct BankAccount { |
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
range(of searchString: String, options: String.CompareOptions, range: Range<String.Index>?, locale: Locale?) |
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
protocol SomeProtocol: class { | |
var aVariable: Int { get set } | |
func increase() | |
} | |
extension SomeProtocol { | |
func increase() { | |
self.aVariable += 1 | |
} | |
} |
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
import Foundation | |
struct GCD { | |
enum Thread { | |
case Main | |
case Static(queue: dispatch_queue_t) | |
case Dynamic(name: String, attribute: QueueAttribute) |
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
import UIKit | |
class ChildViewController: UIViewController { | |
init() { | |
super.init(nibName: nil, bundle: nil) | |
print("Child controller inited") | |
} | |
required init?(coder aDecoder: NSCoder) { |
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
% swift iLoveYou.swift 春彦母 | |
私は春彦母のことが好きです |
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
//普通に distanceTo を使うからこの方法やめる | |
//extension Range where Element: IntegerType { | |
extension Range { | |
//普通に distanceTo を使うからこの方法やめる | |
//var distance: Element { | |
// return self.endIndex - self.startIndex | |
//} | |
var distance: Element.Distance { |
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
class Person { | |
var car: Car? | |
func goForADrive() { | |
self.car?.drive() | |
} | |
func buyGasoline() { |