Create an F # class with the sequence property

Here is the code:

type Advertisement() =
    member val Photos = seq<images> with get,set

but this returns the function signature for the Photos property as

seq<images> -> seq<images>

I just want the property to represent a sequence of images

seq<images>

What am I missing?

+4
source share
2 answers

The problem here is what you want to use seq<images>as a type annotation, but you use it as an expression. They have different meanings; also, it is not clear which sequence you want to assign Photos.

For example, if you want to initialize Photosto an empty sequence, you can use Seq.emptyand have seq<images>as an annotation like:

    member val Photos = Seq.empty : seq<images> with get, set

Or, as ildjarn suggested, use an explicit type parameter for Seq.empty<'T>:

    member val Photos = Seq.empty<images> with get, set

Photos , , :

    member val Photos = Seq.empty with get, set

fuction?

seq<images>, , (.. : ), Operators.seq<'T>, seq<images> -> seq<images>, .

seq ; , . seq<'T> , , , seq { yield 1 }.

+4

seq<images> seq, ,

let foo = seq { yield "bar" }

, F12 seq. , Seq.empty<images>.

+2

Source: https://habr.com/ru/post/1654548/


All Articles