Is Golang duck typed?

alextrending

Alex Rios

Posted on July 6, 2020

Is Golang duck typed?

Hum... Not really!

It's a common misunderstanding because in fact it can relate to the duck type mantra:

If it looks like a duck and quacks like a duck, it's a duck

We can achieve this effect this way

Ok but what is the difference?

Well, the duck typing is resolved in runtime (ruby, python) while in Go it occurs in compile time.

Because of that, in Go it is called structural typing
(sometimes you'll find it named as signature-based polymorphism).

💖 💪 🙅 🚩
alextrending
Alex Rios

Posted on July 6, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Is Golang duck typed?
go Is Golang duck typed?

July 6, 2020