Hide Nav::widget item from a guest

In layouts/main.php, I acknowledge that we can have a different view when we visit as a guest or signed in user by using a ternary operator like this




                    Yii::$app->user->isGuest ? 

			['label' => 'Sign In', 'url' => ['/site/login']]:

                        ['label' => 'Sign Out', 'url' => ['/site/logout']];



However, what I want now is to hide a menu from a guest. I try with the following code but failed.




                    Yii::$app->user->isGuest ? []:

                        ['label' => 'Courses', 'url' => ['/site/courselist']];



What code construction should I have instead?

Have you tried adding columns if only necessary:




if(Yii::$app->user->isGuest) $arrItems[] = ['label' => 'Courses', 'url' => ['/site/courselist']];



Ah ok, I get it now. So we just fill them into an array variable before sending it to Nav::widget. It solve the problem. Thank you Fabrizio!