How to use fields from other records correctly in F#?

Viewed 75

I am currently studying F#, but I am a bit struggling on using records and using their fields. I'd like to use fields from an other record.

Let's say I want to define a Person-record and a Birthday-record.

My code

type DateOfBirth =
{
    Day: int;
    Month: int;
    Year: int;
}

type Person = 
{
    Name: string;
    Birthday: DateOfBirth;
}

I defined my both records without any errors. Now, I am trying to create an actual instance of a person, but I am getting an error on the following code on line (Birthday.Day = 15;).

let John = 
{
    Name = "John";
    Birthday.Day = 15;
    Birthday.Month = 15;
    Birthday.Year = 15;
}

The error message that shows up is saying: "The namespace or module 'Birthday' is not defined".

What I am doing wrong?

1 Answers
Related