Ask HN: Do you use goto, or labeled break/continue?

2026-10-14来源 Hacker News AskEnglish

C# 15 (in preview with .NET 11) lets break and continue target an outer loop by label:

outer: for (int x = 0; x

 for (int y = 0; y 
}

Honestly, "goto" never even comes to mind when I write an algorithm. I find it hard to follow, so when I need to leave nested loops I extract a method and "return" instead.

Do you use "goto" in real code? Do you think you'll use labeled break/continue?

https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-15#labeled-break-and-continue


Comments URL: https://news.ycombinator.com/item?id=50088973

Points: 1

# Comments: 3

原文:https://www.a8q9.cn/en/article/ask-hn-do-you-use-goto-or-labeled-break-continue-f5b250.html

相关文章