1

Goto语句_hanwang的技术博客_51CTO博客

 1 year ago
source link: https://blog.51cto.com/u_15740457/5639958
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Goto语句

精选 原创

在编程中,尽量不要使用goto语句,容易出现bug。

且普遍认为goto语句可以被其他语句替代。

但在某些场景goto语句还是有用的,最常见的用法就是终止程序在某些深度嵌套的结构处理过程。

goto语言真正适合的场景

Goto语句_goto语句

因为多层for循环嵌套,在一个for循环中利用break,作用不大,但goto语言可以直接跳到循环外。

灵魂总结:goto语言就像是飞雷神,而后面的error和循环外面的error就是飞雷神的印记,可以直接跳转。

Goto语句_for循环_02

此为强制关机代码

若两者字符串相同,就可以==0

取消关机\

Goto语句_嵌套_03

Goto语句_goto语句_04
  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK