People
Companies
Institutions
Jobs
Q&A
News
AI Dasatoo
Log in
Home
Courses
Tutors
Books
Q&A
Ask and answer questions to make information more available to wider audiences.
Tags
Latest
Ask Question
Skyler Alcock
@
alcockskyler
23, May 2023 12:00 AM
Enumeration
What is Enumeration in F#?
answers
2
Answer 1
Natalie Jarrett
@
jarrettnatalie
31, May 2023 12:58 PM
Example:
type Year =
| January = 0
| Fabruary = 1
| March = 2
| April = 3
// Use of an enumeration.
let monthName = enum<Year>(3)
printf "%A" monthName
let monthLiteral : Year = Year.January
let n = int monthLiteral
printf "\n%d" n
Answer 2
Noah Antills
@
noahantills
31, May 2023 12:53 PM
Enumeration is popularly known as enums. It is a combination of label and value pair. Labels are assigned to a subset of the values. You can use them in place of literals to make the code more readable and maintainable.