Hacker News new | past | comments | ask | show | jobs | submit login

I think you should take a minute to think about it.

Let me turn it around on you: Give me a simple example in code of something that is mutable and not state.

I'll come back later to check your answer and provide one of my own, if necessary.






OK, here it is:

    int addOne(int value) {
        value += 1;
        return value;
    }
value is clearly mutable, yet not state.

State is a value you can refer to later. Here, "value" doesn't outlive the function, so can't be referred to later.

State is a complication because you have to worry about whether it remains up-to-date.

(Mutable state is even more complex because you also have to worry about if/when it may be changed.)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: