3 ms·
Note, you can do this easily in Go, too: type Kelvin int type Celcius int func SetReactorTemp(temp Celcius) {} func GetOperatingTemp() Kelvin
by NateDad 11y ago
Note, you can do this easily in Go, too:
type Kelvin int
type Celcius int
func SetReactorTemp(temp Celcius) {}
func GetOperatingTemp() Kelvin {}
temp := GetOperatingTemp()
SetReactorTemp(temp) // compile error
- lmm 11y agoYou can, but it quickly becomes infuriating in a language without generics, because you have to repeat any data structure that you want to potentially contain different kinds of temperatures.
- NateDad 11y agoI won't get into it on generics other than to say, in my 2 years of full time development in Go, not having them has not been a big deal.... and no I don't use type unsafe code everywhere either.