Closed mneumann closed 2 years ago
Note ext_ahead!
causes the problem
A constructor always makes a new instance, so if you call a constructor from within another constructor, the expected result is that two instances get created, but the inner one will be discarded because the outer one is the one returned to the caller.
In cases like the one you've shown, I'd usually make ext_ahead
a :fun non
that calls the constructor and returns the resulting instance. From the call site, it looks exactly the same as if ext_ahead
was a constructor.
ah, makes sense. Constructors have no return values.... My fault!
These two should be identical, but they aren't:
Only the second example works!
Note that I have other constructors with single argument that work: