我正在尝试在 F# 中创建一个额外的构造函数来执行一些额外的工作(即读取基本的 csv 文件),如下所示:
type Sheet () =
let rows = new ResizeArray<ResizeArray<String>>()
let mutable width = 0
new(fileName) as this =
Sheet()
then
let lines = System.IO.File.ReadLines fileName
for line in lines do
let cells = line.Split ','
rows.Add(new ResizeArray<String> (cells)) //line 16
if cells.Length > width then width <- cells.Length
但我收到以下错误:
Error 1 The namespace or module 'rows' is not defined C:\Users\ga1009\Documents\PhD\cpp\pmi\fsharp\pmi\Csv.fs 16
Error 2 The value or constructor 'width' is not defined C:\Users\ga1009\Documents\PhD\cpp\pmi\fsharp\pmi\Csv.fs 17
Error 3 The value or constructor 'width' is not defined C:\Users\ga1009\Documents\PhD\cpp\pmi\fsharp\pmi\Csv.fs 17
我究竟做错了什么?