Re: [Vala] Null Coalescing Assignment Operator



Le dimanche 28 mai 2017 à 10:20 +0200, Ulink a écrit :
    thing = thing ? create ();

I think you meant

thing = thing ?? create ();

Yeah, my mistake! Evan actually pointed that out first on IRC.


Edward seems lazy and don't want to write "thing" two times ;-)

What I think we need is an Elvis accessor to turn:

   C? c = null;
    var a = thing_a ();
    if (a != null) {
        var b = thing_b ();
        if (b != null) {
            c = thing_c ();
        }
    }

into:

    var c = thing_a ()?.thing_b ()?.thing_c ();

_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list
-- 
Guillaume Poirier-Morency <guillaumepoiriermorency gmail com>

Étudiant au baccalauréat en informatique à l'Université de Montréal
Stagiaire de recherche à l'IRIC

Mon blog: https://arteymix.github.io/
Clé PGP: B1AD6EA5

Attachment: signature.asc
Description: This is a digitally signed message part



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