Looking to associate strings to ints in a cleaner/more efficient way

前端 未结 8 965
孤街浪徒
孤街浪徒 2021-01-07 07:06

How can I improve this?

The relationship is one to one and continuous on [-1,5] so i was thinking of using enum, but I\'m not sure how to compare a string value to

8条回答
  •  孤城傲影
    2021-01-07 07:34

    You could just use an array or hashmap to map the enum values to the string values.

提交回复
热议问题