Bike rental shop, question about arguments and case statements

I’m at a step of the lesson which I don’t think has been explained, or at least I don’t understand what’s going on:

image

What is happening in the if statement here?
When I say if [[ $1 ]], is that essentially saying if anything is inputted? That is, if $1 exists?
I don’t understand the relation between $1 and the message connected to the ‘any other input’ option in the case statement. How is the condition in the if statement producing the message added next to the * pattern in the case statement?
What does adding a message next to the result of the * pattern do in the first place?

Thank you in advance for your explanations of what’s happening here.

MAIN_MENU "message" is calling the function with the message as an argument - the if [[ $1 ]] is basically, “if an argument is passed to the function → print it.” $1 being the first argument (the message itself).

Thanks so much for the response. I’m afraid I still don’t understand.

I understand that MAIN_MENU “message” is calling the function and printing a message. Is the if statement providing the functionality for a message to be displayed when MAIN_MENU is called? By saying, if an argument is passed to the function then print it? Is it this initial if statement that enables the printing of all the various messages that are attached to calls of the MAIN_MENU function throughout the lesson?
And is the syntax of the if statement something like, if $1 exists, print it? Similar to how [[ -z $1 ]] would mean, if $1 doesn’t exist?

Thanks again

yes @chriswallacet, if [[ -z $1 ]] and if [[ $1 ]] would effectively do the same thing - check if the argument is not empty. If so, it prints the argument. So when you use MAIN_MENU <message> throughout the code, the <message> would be the $1, and it will print the different messages.

Thanks, I understand now. Is there a functional benefit to doing it like this instead of just echoing a message each time MAIN_MENU is called and not bothering with this little if statement at the top of the file?

Is there a functional benefit…

No, that would produce the same result I presume - and would have been a better way to do it.

That’s the way I ended up doing it, this way is how it’s shown in the FCC lesson. Thanks for all your help and explanations mate