This file contains 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 A { | |
func protocolAFunc (); | |
} | |
protocol B { | |
func protocolBFunc (); | |
} | |
struct Sample { | |
func protocolAFunc() { |
This file contains 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 A { | |
func protocolFunc (); | |
} | |
protocol B { | |
func protocolFunc (); | |
} | |
struct Sample { | |
} |
This file contains 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 MyProtocol { | |
func method1() -> String | |
} | |
extension MyProtocol { | |
func method1() -> String { | |
return "protocol (1)" | |
} | |
func method2() -> String { |
This file contains 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
func myDebugPrint(@autoclosure item: () -> String) { | |
#if DEBUG | |
print(item()) | |
#endif | |
} | |
myDebugPrint("aaa") |
This file contains 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
func myDebugPrint(@autoclosure item: () -> String) { | |
#if DEBUG | |
print(item()) | |
#endif | |
} | |
class Sample { | |
func hoge() -> String { | |
// 重い処理 | |
return "aaaa" |
This file contains 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
func myDebugPrint(@autoclosure item: () -> String) { | |
#if DEBUG | |
print(item()) | |
#endif | |
} | |
class Sample { | |
func hoge() -> String { | |
// 重い処理 | |
return "aaaa" |
This file contains 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 MyForwardIndexTypeStruct { | |
var num: Int | |
init(_ num: Int) { | |
self.num = num | |
} | |
} | |
// Equatable | |
func == (lhs: MyForwardIndexTypeStruct, rhs: MyForwardIndexTypeStruct) -> Bool { | |
return lhs.num == rhs.num |
This file contains 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 MyForwardIndexTypeStruct { | |
var num: Int | |
init(_ num: Int) { | |
self.num = num | |
} | |
} | |
// Equatable | |
func == (lhs: MyForwardIndexTypeStruct, rhs: MyForwardIndexTypeStruct) -> Bool { | |
return lhs.num == rhs.num |
This file contains 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 ActionDelegate { | |
let member = "ActionDelegate" | |
} | |
class DelegateSampleClass { | |
weak var delegate : ActionDelegate! | |
init (delegate: ActionDelegate) { | |
self.delegate = delegate | |
} | |
func notOptional() { |
This file contains 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 HogeProtocol { | |
init(name: String) | |
} | |
class HogeClass : HogeProtocol { | |
required init(name: String) { // HogeProtocol の init(name: String) 必須 | |
} | |
} | |
class Hige : HogeClass { | |
required init(name: String) { // HogeProtocol の init(name: String) 必須 |