本文介绍了如何避免在F#中进行硬编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的最佳实践到底是什么-显然不支持#define,所以定义常量的最佳方法是什么,例如

What exactly is the best practice here - clearly #define isn't supported so what is best way to define constants like

SPACE =''

冒号=':'

STATE_START = 0

STATE_START = 0

STATE_IDENT = 1

STATE_IDENT = 1

STATE_COMMENT = 2

STATE_COMMENT = 2

等等等.

Thx

Cap'n

推荐答案

let space = ' '
let colon = ':'

// Multiple "State"s sounds like a union to me...
type MyState =
  | Start
  | Ident
  | Comment


这篇关于如何避免在F#中进行硬编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 07:11
查看更多