Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    CQS though would imply that modifying state and getting results should be separated Commented Feb 13, 2018 at 11:23
  • 7
    @jk. As usual: in general you should separate state change and returning a result but in rare cases there are valid reasons to combine that. E.g.: an iterators next() method shouldn't only return the current object but also change the iterators internal state so that the next call returns the next object... Commented Feb 13, 2018 at 11:29
  • 4
    Exactly. I think OP’s problem is simply due to misunderstanding/misapplying “tell, don’t ask”. And fixing that misunderstanding makes the problem go away. Commented Feb 13, 2018 at 15:46
  • @KonradRudolph Plus, I don't think that's the only misunderstanding here. Their description of a "pure function" includes "Its state is set only once." Another comment indicates it could mean a closure's context, but the phrasing sounds odd to me. Commented Feb 14, 2018 at 14:17