Useful alternative control structures?

后端 未结 28 976
礼貌的吻别
礼貌的吻别 2021-01-30 02:20

Sometimes when I am programming, I find that some particular control structure would be very useful to me, but is not directly available in my programming language. I think my

28条回答
  •  梦毁少年i
    2021-01-30 03:15

    for int i := 0 [down]to UpperBound() [step 2]
    

    Missing in every C-derived language.

    Please consider before you vote or write a comment:
    This is not redundant to for (int i = 0; i <= UpperBound(); i++), it has different semantics:

    1. UpperBound() is evaluated only once

    2. The case UpperBound() == MAX_INT does not produce an infinite loop

提交回复
热议问题