|
|
|
|
|
by SideburnsOfDoom
2109 days ago
|
|
> While true, if your language doesn’t support such a type You'd be surprised where the support is. In C#, you would declare a struct type with one read only field of type double, and range validation (x <= x <= 1) in the constructor. this is the "value object" pattern. http://wiki.c2.com/?ValueObject Yes there's a bit of boilerplate - especially since you might want to override equality, cast operators etc. But there is support. And with a struct, not much overhead to it. |
|