主要是使用场景不同

for可以

遍历array和slice

遍历key为整型递增的map

遍历string

for range可以完成所有for可以做的事情,却能做到for不能做的,包括

遍历key为string类型的map并同时获取key和value

遍历channel

相关文章:

  • 2022-02-14
  • 2022-02-03
  • 2022-12-23
  • 2022-01-20
  • 2021-10-14
  • 2022-02-16
  • 2022-01-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-21
  • 2021-08-20
  • 2021-09-06
  • 2021-06-20
  • 2021-04-13
  • 2022-12-23
相关资源
相似解决方案