First-Class Function
noun
say it: “FURST-klas FUNK-shun” /ˈfɜrstˌklæs ˈfʌŋkʃən/
A function a language treats as a value, so it can be stored in a variable, passed to another function, or returned.
What is a first-class function?
A language has first-class functions when a function is a value like any other: you can store it in a variable, pass it to another function, keep it in a list, or return it. C#, Java, Python, JavaScript and TypeScript all do, which is how a checkout can be handed this week's discount as a function.
weekend = lambda total: total * 80 // 100
print(weekend(65)) # 52
In a sentence
- “Because C# has first-class functions, checkout can be handed this week's discount as a value.”
Level: Journeyman · More Software Development terms at this level
Updated