Re:Is Go Duck-Typed?
by mrkeen on Saturday March 07, 2020 @11:21AM
(#22512324)
> you probably wanted to use a type other than string for the return type.
That's the point. In order for (String userId) to not be confused with (String password), I wrap them with nominal types UserId and Password.
If the language looks at both UserId and Password and decides they're interchangeable because they both satisfy the contract 'contain a String', then that completely negates the point.
That's the point. In order for (String userId) to not be confused with (String password), I wrap them with nominal types UserId and Password.
If the language looks at both UserId and Password and decides they're interchangeable because they both satisfy the contract 'contain a String', then that completely negates the point.