Using keywords as identifiers in F#

2020-01-27 06:02发布

In C#, I can do the following:

int @private = 15;

And in VB.NET, I can do the following:

Dim [Private] As Integer = 15

I am wondering if there is a way in F# to use reserved keywords as identifiers, like there is in VB.NET and C#?

1条回答
成全新的幸福
2楼-- · 2020-01-27 06:42

Given section 3.4 of the F# 2.0 spec:

Identifiers follow the specification below. Any sequence of characters that is enclosed in double-backtick marks (`` ``), excluding newlines, tabs, and double-backtick pairs themselves, is treated as an identifier.

I suspect you can put it in backticks:

``private``

I haven't tried it though.

查看更多
登录 后发表回答