Is perl's each function worth using?

后端 未结 8 1670
忘掉有多难
忘掉有多难 2021-01-17 11:37

From perldoc -f each we read:

There is a single iterator for each hash, shared by all each, keys, and values

8条回答
  •  一整个雨季
    2021-01-17 12:09

    each is not only worth using, it's pretty much mandatory if you want to loop over all of a tied hash too big for memory.

    A void-context keys() (or values, but consistency is nice) before beginning the loop is the only "workaround" necessary; is there some reason you are looking for some other workaround?

提交回复
热议问题