Are multiple conditional operators in this situation a good idea?

前端 未结 21 2915
名媛妹妹
名媛妹妹 2020-12-15 06:23

I just saw this block of code on the Wikipedia article on conditional operators:

Vehicle new_vehicle = arg == \'B\' ? bus      :
                      arg ==         


        
21条回答
  •  孤城傲影
    2020-12-15 07:24

    How about:

    enum Vehicle { bus = 'B', airplane = 'A', train, car = 'C', horse = 'H', feet = 'F' };
    ...
    new_vehicle = arg;
    

    :-), by the way.

提交回复
热议问题