Dav*_*peš 5 f# azure azure-functions
为什么不#load工作
我已经在相同的文件夹和相关文件夹中尝试了它,如下所示
我错过了什么?
run.fsx是
#load "../shared/shared.fsx"
let key = "MyKey"
let Run(message: string, log: TraceWriter, result: byref<string>) =
result <- doItAll message key
log.Info(sprintf "F# results: %s" result)
Run Code Online (Sandbox Code Playgroud)
shared.fsx是
let doItAll message key = key + " has handled " + message
Run Code Online (Sandbox Code Playgroud)
错误是
run.fsx(x,y): error FS39: The value or constructor 'doItAll' is not defined
Run Code Online (Sandbox Code Playgroud)
如果未明确指定命名空间或模块名称shared.fsx,则F#编译器会将文件中的代码放入隐式命名的模块中Shared.您应该能够通过添加open Shared以下内容来修复错误:
#load "../shared/shared.fsx"
open Shared
let key = "MyKey"
let Run(message: string, log: TraceWriter, result: byref<string>) =
result <- doItAll message key
log.Info(sprintf "F# results: %s" result)
Run Code Online (Sandbox Code Playgroud)
如果您想自己控制命名,您还可以添加module声明shared.fsx并自己给出一个明确的名称:
module SharedStuff
let doItAll message key = key + " has handled " + message
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
60 次 |
| 最近记录: |