[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Functions with multiple optional arguments
From: |
Heime |
Subject: |
Re: Functions with multiple optional arguments |
Date: |
Mon, 17 Oct 2022 05:42:53 +0000 |
------- Original Message -------
On Monday, October 17th, 2022 at 4:05 AM, Jean Louis <bugs@gnu.support> wrote:
> * Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org
> [2022-10-17 00:06]:
>
> > Have been writing a function that has two optional arguments. It is
> > turning out to be a difficult task in situations when one in missing
> > an argument. Anybody has experience about this, as I have not seen
> > much code with multiple optional arguments.
>
>
> If argument is optional but required by your function, I use this method:
>
> (defun my-fun (&optional title description)
> (let ((title (or title "Best Movie"))
> (description (or description "Description")))
> (message "%s: %s" title description)))
>
> (my-fun)
I see that the trick is to assign defaults that way. I like it, very clever.
Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/17
- Re: Functions with multiple optional arguments, Jean Louis, 2022/10/17
- Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/18
- Re: Functions with multiple optional arguments, Jean Louis, 2022/10/20
- Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/22
- Re: Functions with multiple optional arguments, Jean Louis, 2022/10/23