Constrained Generics syntax

Is this the correct syntax for a constrained generic? The Oxygene docs on generics do not show a semicolon at the end of the where statement, but the compiler seems to require it.

type
  BaseView<T> = public class
    where T is BasePresenter;
  public
    method SetPresenter (presenter: T); virtual;
  end;

Thanx, I’ll check with the team, and update docs if necessary,

1 Like

Sorry yes. The semicolon is required.

1 Like

Docs fixed.

Not fixed for this sample, on the same doc page:

type
  List<T> = public class
    where T is IComparable, T has constructor
  public

    method New: T;  
    begin
      result := new T; // made possible because of `where T has constructor`
      Add(result);
    end;
    
    method Sort();
    begin
      ... complex sorting code
      if self[a].CompareTo(self[b]) then // made possible by `where T is IComparable`
        Switch(a,b);
      ... more complex sorting code
    end;