mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
34 lines
489 B
Swift
34 lines
489 B
Swift
|
|
#if BEFORE
|
|
|
|
public class ChangeLazyToComputed {
|
|
private var celsius: Int
|
|
|
|
public init(celsius: Int) {
|
|
self.celsius = celsius
|
|
}
|
|
|
|
public lazy var fahrenheit: Int = (celsius * 9) / 5 + 32
|
|
}
|
|
|
|
#else
|
|
|
|
public class ChangeLazyToComputed {
|
|
private var celsius: Int
|
|
|
|
public init(celsius: Int) {
|
|
self.celsius = celsius
|
|
}
|
|
|
|
public var fahrenheit: Int {
|
|
get {
|
|
return (celsius * 9) / 5 + 32
|
|
}
|
|
set {
|
|
celsius = ((newValue - 32) * 5) / 9
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|