Compares value with expected and replaces it with new value if values matches.
true if successful, false if state is unchanged
the expected value
the new value
Thanks for your feedback!