Swift를 공부하면서 Delphi를 재정립하자.
Structure
//Swift
struct Resolution {
var width = 0;
var height = 0;
}
let hd = Resolution(width: 1920, height: 1080)
var someResolution = Resolution(width: 640, height: 480)
struct Resolution {
var width = 0;
var height = 0;
}
let hd = Resolution(width: 1920, height: 1080)
var someResolution = Resolution(width: 640, height: 480)
//Delphi
type
TResolution = record
width: integer;
height: integer;
end;
const
hd: TResolution = (width: 1920; height: 1080);
var
someResolution: TResolution = (width: 640; height: 480);
type
TResolution = record
width: integer;
height: integer;
end;
const
hd: TResolution = (width: 1920; height: 1080);
var
someResolution: TResolution = (width: 640; height: 480);
//Swift
- @propertyWrapper
- struct TwelveOrLess {
- private var number = 0
- var wrappedValue: Int {
- get { return number }
- set { number = min(newValue, 12) }
- }
- }
- //Delphi
- type TResolution = record private number : integer; function getWappedValue: integer; procedure setWappedValue(const Value: integer); property wrapValue: integer read number write number; property wrappedValue: integer read getWappedValue write setWappedValue; end;
- function TResolution.getWappedValue: integer;
- begin
- Result:= number;
- // willSet
- end;
- procedure TResolution.setWappedValue(const Value: integer);
- begin
- if Value > 0 then
- number:= Value
- else Value := 0;
- // didSet
- end;
댓글 없음:
댓글 쓰기