help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Executing part of the code instead of another


From: Christopher Dimech
Subject: Re: Executing part of the code instead of another
Date: Wed, 7 Oct 2020 15:09:26 +0200

I have tried executing the following condition (if (nb > na))

(setq na 2)
(setq nb 5)
( if (> nb na)
    (message "nb > na [condition true]")
    (message "condition false")
)

I highlighted the region then pressed C-x C-e
It returned the first message as expected, but when I tried
the next one, I still got the first message.

(setq na 2)
(setq nb 1)
( if (> nb na)
    (message "nb > na [condition true]")
    (message "condition false")
)




> Sent: Wednesday, October 07, 2020 at 9:20 AM
> From: "Robert Pluim" <rpluim@gmail.com>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: moasenwood@zoho.eu, help-gnu-emacs@gnu.org
> Subject: Re: Executing part of the code instead of another
>
> >>>>> On Wed, 7 Oct 2020 09:01:00 +0200, Christopher Dimech <dimech@gmx.com> 
> >>>>> said:
>
>     Christopher> What can one use if there is an else branch with multiple 
> commands, as I would
>     Christopher> like to use it.
>
> From 'C-h f if'
>
>     if is a special form in `C source code'.
>
>     (if COND THEN ELSE...)
>
>       Probably introduced at or before Emacs version 1.1.
>
>     If COND yields non-nil, do THEN, else do ELSE...
>     Returns the value of THEN or the value of the last of the ELSE's.
> =>  THEN must be one expression, but ELSE... can be zero or more expressions.
>     If COND yields nil, and there are no ELSE's, the value is nil.
>
>
> Robert
> --
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]