Skip to content

Instantly share code, notes, and snippets.

@nkmrh
Created July 29, 2020 07:10
Show Gist options
  • Save nkmrh/f45fe881c6a7e3e9bcfe43b4c528791b to your computer and use it in GitHub Desktop.
Save nkmrh/f45fe881c6a7e3e9bcfe43b4c528791b to your computer and use it in GitHub Desktop.
レガシーコード改善ガイド 4.2 接合部
import Foundation
class Hoge {
func fuga() {
// .........................
// .........................
// .........................
// .........................
let v = min(2, 1)
print(v)
// .........................
// .........................
// .........................
// .........................
}
func min(_ x: Int, _ y: Int) -> Int {
return Swift.min(x, y)
}
}
class TestingHoge: Hoge {
override func min(_ x: Int, _ y: Int) -> Int {
return 1000
}
}
Hoge().fuga() // 1
TestingHoge().fuga() // 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment