Difference between pure and impure function?

后端 未结 5 1259
再見小時候
再見小時候 2020-12-03 01:34

I assumed that pure functions must always have a return type (i.e., must not be void) and must have the same output regardless of the state of the object and th

5条回答
  •  孤城傲影
    2020-12-03 02:16

    Mu. You seem to be assuming that an accessor is a pure function by definition. This is not necessarily the case -- an accessor (even a get-accessor returning a value) may be impure, such as the get method of LinkedHashMap when in access-order mode (which moves the requested entry to last position in iteration order).

提交回复
热议问题