3 ms·
You have a small syntax error on your third example, it should be var DefaultPi float64 = 3.141592
by codnee 9y ago
You have a small syntax error on your third example, it should be
var DefaultPi float64 = 3.141592
- aant 9y agoThank you! I'll update it as soon as I can.
- grey-area 9y agoIf you're updating it anyway, perhaps consider not using Pi as a config value in the first place.
- white-flame 9y agoNot to mention that there aren't enough digits there to fill the precision of a 64-bit float.
- deleted 9y ago[deleted]
- alecbenzer 9y agoI was so confused with `type DefaultPi float64 = 3.141592`... I thought Go had started supporting defining custom default values for types and then interpreting `type` as its default value when used in expressions....
- wangii 9y agohow about `const DefaultPi = 3.14159265`
- curun1r 9y agoThe funny thing is that there are languages that allow constants into the type system. The feature has a few names, but one of them is pi-types (well, π-types) [1]. Go even uses them for its array types. However like generics, it's not a feature of the type system that can be used outside the built-in types. [1] https://en.wikipedia.org/wiki/Dependent_type#Formal_definition https://en.wikipedia.org/wiki/Dependent_type#Formal_definiti...