F # variable list is zero

When I try to run the code below, the properties are null. Why is this? I assign an empty list to properties, but for the first time through the loop, it is zero.

This makes him discard the first value that I add to it. I don’t get it either. It seems that the value associated with the null value should be a list of values.

[<TechTalk.SpecFlow.Binding>]
module FSharpLeftistHeapStepDefinition

open TechTalk.SpecFlow

let mutable properties = [0]
let [<Given>] ``I have a list with the following numbers``(values:Table) = 
    let rec insertItems i =
        if i < 0 then ()
        else 
            let value = int ((values.Rows.Item i).Item 0)            
            properties <- value::properties
            insertItems (i-1)

    insertItems (values.RowCount - 1)

It is very strange.

[Modify] Decision based on Tarmil's answer

 [<Binding>]
 type Example ()= 
     let mutable properties = []
     let [<Given>] ``I have a list with the following numbers``(values:Table) = 
         let rec insertItems i =
             if i < 0 then ()
             else 
                 let value = int ((values.Rows.Item i).Item 0)            
                 properties <- value::properties
                 insertItems (i-1)

         insertItems (values.RowCount - 1)
+4
source share
1 answer

, [<Given>] , , . [0] , , , , null.

+3

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


All Articles