Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 883 Bytes

File metadata and controls

29 lines (21 loc) · 883 Bytes

First-class Objects

Know that a function is a first-class object in functional programming languages and in imperative programming languages that support such objects. This means that it can be an argument to another function as well as the result of a function call.

When calling a function, the name given to a type of object which can be passed in or returned is first-class object.

A first class object is any object / value which may:

  • appear in expressions
  • be assigned to a variable
  • be assigned as arguments
  • be returned in function calls

Examples of First Class Objects

  1. Integer
  2. Floating-point values
  3. Characters
  4. Strings

First Class Objects in Functional Programming

In functional languages, functions are treated as first class objects.

This is what enables ideas such as currying and partial application to become reality.