Discussion:
use end or endif is indifferent?
shivax
2018-11-28 17:04:34 UTC
Permalink
hi


I used "end" instead of "endif" in cycles
it's indifferent?




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
shivax
2018-11-28 16:25:52 UTC
Permalink
hi


I used "end" instead of "endif" in cycles
it's indifferent?




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Przemek Klosowski
2018-11-28 17:36:53 UTC
Permalink
I used "end" instead of "endif" in cycles ... it's indifferent?
Please clarify---perhaps you used 'end' after an 'if' block contained in
a 'for' loop, and you wonder if it ends the 'if' or the 'for' block?

for i=1:10

 if i==5

     i

 end

end


'end' nests, so it should work properly, as you can see by running the
above code. Of course it will also work , and will be more readable, if
you write it like this

for i=1:10

 if i==5

     i

 endif
gigiolone123
2018-11-28 19:37:50 UTC
Permalink
i've used it to close if statement


thank you for answer




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
shivax
2018-11-28 19:43:03 UTC
Permalink
thank you for answer

i use it to close statement if



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Marco Atzeri
2018-11-28 17:32:42 UTC
Permalink
Post by shivax
hi
I used "end" instead of "endif" in cycles
it's indifferent?
not clear what you mean for "cycles"

you can use "end" instead of "endif" for closing
a "if" statement, but it is not recommended

https://octave.org/doc/interpreter/Statements.html#index-end-statement

---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
ht
gigiolone123
2018-11-28 19:37:02 UTC
Permalink
thank you



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
shivax
2018-11-28 19:43:30 UTC
Permalink
thank you for answer



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Sergei Steshenko
2018-11-29 00:03:19 UTC
Permalink
Post by shivax
hi
I used "end" instead of "endif" in cycles
it's indifferent?
not clear what you mean for "cycles"

you can use "end" instead of "endif" for closing
a "if" statement, but it is not recommended

https://octave.org/doc/interpreter/Statements.html#index-end-statement

---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprÃŒft.
https://www.avast.com/antivirus


=============================
'not clear what you mean for "cycles"' - most likely loops. In Russian "cycles" is used instead of "loops". Probably not only in Russian.
--Sergei.
inor0627
2018-11-29 07:00:59 UTC
Permalink
On Wednesday, November 28, 2018, 7:52:48 PM GMT+2, Marco Atzeri <
you can use "end" instead of "endif" for closing
a "if" statement, but it is not recommended
https://octave.org/doc/interpreter/Statements.html#index-end-statement
Hello Sergei,

this is correct for Octave, but please keep in mind that Matlab (2016a) does
not support "endif" and "endfor". So when you have to cooparate with people
using Matlab, you could instead use "end%if" and "end%for" which will
increase readability of your code, though you will losse Octave's advanced
diagnostic abilities as mentioned in your link.

inor



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Ardid Ramirez, Joan Salvador
2018-11-29 13:43:04 UTC
Permalink
Hello Sergei,

this is correct for Octave, but please keep in mind that Matlab (2016a) does
not support "endif" and "endfor". So when you have to cooparate with people
using Matlab, you could instead use "end%if" and "end%for" which will
increase readability of your code, though you will losse Octave's advanced
diagnostic abilities as mentioned in your link.


Mmm, thinking about it, it would actually be great if Octave would accept end%if as an alias of endif and end%for as an alias of endfor. This would bring the best of the two worlds, keeping all Octave's goodness, while keeping Matlab compatibility.

Sending it to maintainers to see if Octave Devs would consider this as a feasible option...

....
a.

Loading...