tw36362.pp 486 B

12345678910111213141516171819202122232425262728293031
  1. {$mode objfpc}
  2. {$modeswitch objectivec2}
  3. program test;
  4. uses
  5. CocoaAll;
  6. type
  7. tc = objcclass(NSObject)
  8. a: char;
  9. end;
  10. operator := (const right: array of const): NSMutableArray;
  11. begin
  12. if tc(right[0].vPointer).a<>'a' then
  13. halt(1);
  14. result:=NSMutableArray.alloc.initWithCapacity(1);
  15. result.addObject(tc(right[0].vPointer));
  16. end;
  17. var
  18. c: tc;
  19. a: NSMutableArray;
  20. begin
  21. c:=tc.alloc.init;
  22. c.a:='a';
  23. a := [c];
  24. for c in a do
  25. if c.a<>'a' then
  26. halt(2);
  27. end.