Pure function
Table of Contents
Pure Function
Overview
A pure function is a central concept in Functional Programming. For a function to be considered pure, it must meet two specific criteria:
- No Side Effects: The function must not cause any observable changes outside of its own scope. This means it cannot modify external variables, write to a database, log to the console, or perform any other I/O operations.
Because of these properties, pure functions are highly predictable and reliable. This makes code that uses them easier to test, debug, and reason about. Their lack of reliance on shared state also makes them inherently safe for Concurrency operation, as they help prevent race conditions.