作为 F# 的新手,我很难理解为什么会出现此错误。以下是我承认的琐碎且多余的代码:
open System
open System.Globalization
let toUpperCase (input: string) =
input.ToUpper()
let uCaseAll (input: string) =
input.Split()
|> Array.map toUpperCase
|> String.concat " "
[<EntryPoint>]
let main argv =
let text = "You’re in the right place. Tell us what titles or genres you’ve enjoyed in the past, and we’ll give you surprisingly insightful recommendations."
printfn "Result: %s" uCaseAll text
我收到的错误是:
Type mismatch. Expecting a
'string -> 'a -> int'
but given a
'string -> unit'
The type ''a -> int' does not match the type 'unit'
This expression was expected to have type
'string'
but here has type
'string -> string'
这让我很困惑,因为我的函数明确定义为接受字符串并返回字符串。但编译器认为我正在使用int
s 和uint
s 做一些事情。
我做错什么了?