Notes
- Why a type method that should return a string returns a 'unit -> string' instead and how to solve it? does not answer my question because it refers to incorrect input, while I do not have it.
I'm currently having a problem with the functions "ToString" returning a (unit -> string) type and not a string, and "ToArray" returning (unit -> string[]) and not string[]. Attempting to upcast to string[] or string has no success.
Here is the code:
let readZip filepath = ZipFile.OpenRead filepath
let replaceEnvs str = Environment.ExpandEnvironmentVariables str
let listFiles rawDir =
replaceEnvs rawDir
|> Directory.EnumerateFiles
let readModMetadata filepath =
let archive = readZip filepath
(archive.GetEntry "mcmod.info").ToString // Also becomes (unit -> string) and not string
[<EntryPoint>]
let main args =
let mods = listFiles modsFolder
let modAsArray = mods.ToArray // Becomes (unit -> string[]) and not string[]?
0
Why is this so, and is there a way to get only strings?
CodePudding user response:
So I found it out.
You need to specify that no parameters go into the functions. The parenthesis in ToString()
do just that.
I need more coffee.