Re:The Value in Go’s Simplicity
by lowmagnet on Saturday November 16, 2019 @04:27PM
(#21555061)
A colorer would return a color regardless of its type. This is behavior-based interface. I just need a thing that when I call Color(), you get a *Color.
[ Parent
| on HN ]
Re:The Value in Go’s Simplicity
by atombender on Saturday November 16, 2019 @07:14PM
(#21555765)
That's not an enum or sum type, though, and misses the point of my example. For colors, sure, you can use a structural type to represent RGBA, but that wasn't what I was trying to get across. What if the set of possible values cannot be described as scalars? The other example with "actions" demonstrated this problem.