How does Go achieve implicit interface implementation?

  • By using type assertions.
  • By using type conversion.
  • By using type embedding.
  • By using type inference.
Go achieves implicit interface implementation through type embedding. In Go, if a type contains another type as a field, it automatically implements the methods of that inner type. This allows for seamless interface implementation without explicitly declaring it.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *