4 ms·
Note that while interface upgrades are very usefull to use, they are not something very new in the programming language world. In java you could do: if (rea
by TeeWEE 12y ago
Note that while interface upgrades are very usefull to use, they are not something very new in the programming language world.
In java you could do:
if (reader instanceOf BufferedReader) {
// upgrade
BufferedReader bReader = (BufferedReader) reader;
}
This is actualy adviced NOT to do, since its really a runtime type check.
In Go its no different, as this article explains. However its still a usefull mechanism sometimes.