[Vala] not null 'this' in constructors



Hello list.

Is 'this' always null in constructors? The following code produces a
run-time error:

public class Foo
{
    Foo()
    {
        assert( this != null );
    }
}

Is there a way to get the true value of this in the constructor? I guess,
probably not. As far as I understand references in vala are somewhat
similar to shared_ptr<> pointers in C++ and vala classes to
enable_shared_from_this<> C++ subclasses. If the reasons are also similar,
it would be sad.

But probably vala gives a solution to this?


BR, Vitaly Kirsanov
skype: vkirsan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]