如何让两个方法互相调用? [英] How to have two methods calling each other?

查看:15
本文介绍了如何让两个方法互相调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对如何让两个方法相互调用有点困惑(即,有 A() call B()B() 调用 A()).似乎 F# 仅在代码中遇到该方法后才看到"该方法,因此如果没有,它只会说值或构造函数尚未定义.

I'm a bit confused as to how to get two method to call each other (i.e., have A() call B() and B() call A()). It seems that F# only 'sees' the method after it's been encountered in code, so if it hasn't, it just says value or constructor has not been defined.

我在这里遗漏了一些非常基本的东西吗?

Am I missing something very basic here?

推荐答案

'let rec... and...' 是您寻求的语法.

'let rec... and...' is the syntax you seek.

let rec F() = 
    G()
and G() =
    F()

另见 F# Co 的冒险-递归.

这篇关于如何让两个方法互相调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆