assertion asserts that a value is of T type
And what does cast do?
converts one type into another
And if it fails?
u should get a compiler error that a type is not convertible into another one or it will just not tell u anything if it's a weakly typed language
type assertion: I assert it's T, if not, panic. casting: I will treat this piece of memory as T
Good thing Go has the ,ok syntax when asserting
we also have type-switches
I mean when asserting
Обсуждают сегодня