end语句可以代替Octave中的endfor语句吗? [英] Can end statement replace endfor statement in Octave?

查看:93
本文介绍了end语句可以代替Octave中的endfor语句吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

链接说明了我们应该使用 endfor 语句以关闭 for 循环的范围.

但是将其替换为 end 会导致相同的行为.

使用 end 而不是 endfor 有任何意外的副作用吗?

解决方案

end 在关闭 for 循环时与 endfor 同义./p>

使用 end 的唯一副作用是您的代码也将与MATLAB兼容,因为 endfor 是Octave发明的语言的扩展.我建议您不要使用 endfor 等( endif endfunction endswitch endwhile等)).

This link illustrates that we should use endfor statement to close the scope of for loop.

But replacing it with end results into the same behavior.

Does using end rather than endfor have any unexpected side effects?

解决方案

end is synonymous with endfor when closing a for loop.

The only side effect of using end is that your code will also be compatible with MATLAB, as endfor is an extension of the language invented by Octave. I recommend that you do not use endfor and the like (endif, endfunction, endswitch, endwhile).

这篇关于end语句可以代替Octave中的endfor语句吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆