Why do I need underscores in swift?

后端 未结 4 632
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 16:51

Here it says, \"Note: the _ means “I don’t care about that value”\", but coming from JavaScript, I don\'t understand what that means.

The only way I can

4条回答
  •  感情败类
    2020-11-30 17:25

    In addition to the accepted answer, one of the use cases of _ is when you need to write a long number in code

    More readable number

    This is not easy human readable:

    let x = 1000000000000
    

    You can add _ in the number to make it more human readable:

    let x = 1_000_000_000_000
    

提交回复
热议问题