F#, the value or constructor 'List' is not defined

Viewed 719

I am copying this code out of a book on F#. The compiler is supposed to create a generic function.

Instead, I am getting an error

"FS0039: The value or constructor 'List' is not defined."

Why?

let createList(first, second) = 
    let output = List()
    output.Add(first)
    output.Add(second)
    output

// expected output below
// val createList : first:'a * second:'a -> List<'a>
1 Answers

I added this line to the script

open System.Collections.Generic 

unlike C#, Visual Studio F# isn't good at telling you when you need to add an open statement like this.

Related