use end or endif is indifferent?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

use end or endif is indifferent?

shivax
hi


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




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: use end or endif is indifferent?

Przemek Klosowski-7
On 11/28/18 11:25 AM, shivax wrote:
> 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

endfor

but it won't be compatible with Matlab...




Reply | Threaded
Open this post in threaded view
|

Re: use end or endif is indifferent?

shivax
thank you for answer

i use it to close statement if



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html