2021년 7월 22일 목요일

swift vs delphi: 01

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) 

//Delphi
type
  TResolution = record
    width: integer;
    height: integer;
  end;
const
  hd: TResolution = (width: 1920; height: 1080);
var
  someResolution: TResolution = (width: 640; height: 480);

//Swift
  1. @propertyWrapper
  2. struct TwelveOrLess {
  3. private var number = 0
  4. var wrappedValue: Int {
  5. get { return number }
  6. set { number = min(newValue, 12) }
  7. }
  8. }

  9. //Delphi
  10. 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;

  11. function TResolution.getWappedValue: integer;
  12. begin
  13.   Result:= number;
  14.   // willSet
  15. end;
  16. procedure TResolution.setWappedValue(const Value: integer);
  17. begin
  18.   if Value > 0 then
  19.     number:= Value
  20. else Value := 0;
  21.   // didSet
  22. end;


댓글 없음:

델파이 12.1이냐 11.3이냐?

 델파이가 12.1이 나왔습니다. 혹시 11.3버전의 커뮤니티버전이 필요하시는분이 있을 수 있을 것 같아 https://altd.embarcadero.com/.../RADStudio_11_3_esd_28... 와 이것 찾느랴 엄청고생함.