且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何避免在F#中进行硬编码

更新时间:2022-12-22 15:12:27

首先-我会想一想为什么要这些.  但是在F#中,每个值实际上已经是常量(因为默认情况下它们是不可变的),所以我只使用:

First off - I'd think about why you want these in the first place.  But in F#, every value is effectively already constant (since they're immutable by default), so I'd just use:

let space = ' '
let colon = ':'

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