Skip to content

Chapter 3 why decrement hp is a pure function if it modifies input argument #643

Open
@happytomatoe

Description

Why decrement hp is a pure function if it modifies input argument -
const decrementHP = p => p.set('hp', p.get('hp') - 1);
For it to be pure shouldn't it at least copy the map content before changing the value? If you run this in multithreaded env you will get a lot of troubles.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions