single-expression function

noun
UK /ˈsɪŋɡəl ɪkˈspreʃən ˈfʌŋkʃən/
US /ˈsɪŋɡəl ɪkˈspreʃən ˈfʌŋkʃən/

A tiny helper that does one job and gives back an answer right away.

She wrote a single-expression function to add two numbers in one line.


OTHER MEANINGS

2. A function whose whole body is just one expression, with no extra statements.

In many languages, a single-expression function skips the return keyword.

3. A short piece of code that computes a value without storing it in a variable first.

The map call took a single-expression function to double each item.

4. A compact way to write a small routine, often used for quick tasks.

He replaced the long method with a single-expression function for clarity.