There's a slight inconsistency in the way the this pointer works between assigning to a variable and directly returning it.
Assigning to a variable gives you Ptr, while returning gives you SharedPtr.
class FooBuilder {
public function new() {}
public function withBar() {
// return this // <-- works
var r = this;
return r; // <-- does not work: Cannot convert unsafe pointer (Ptr<T>) to shared pointer (SharedPtr<T>).
}
}
function main() {
new FooBuilder().withBar();
}
There's a slight inconsistency in the way the
thispointer works between assigning to a variable and directly returning it.Assigning to a variable gives you
Ptr, while returning gives youSharedPtr.