In type assertion, what happens if the assertion fails in Go?

  • AssertionError is raised
  • Compilation error
  • Panic occurs
  • nil is returned
In Go, if the type assertion fails, it will cause a panic. This means that if the type assertion does not hold true at runtime, the program will panic and may terminate abruptly. Therefore, it's essential to handle type assertion failures appropriately to avoid unexpected crashes in Go programs.
Add your answer
Loading...

Leave a comment

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