paxPayment, ok = dataObject.(*entities.PassengerPayment)
What are the brackets used for? I'm not sure what is going on in this assignment operation.
Do you need any more details to answer this question?
paxPayment, ok = dataObject.(*entities.PassengerPayment)
What are the brackets used for? I'm not sure what is going on in this assignment operation.
Do you need any more details to answer this question?
It's simply a Type assertion. A type assertion can be used to:
Quoting from the spec:
More specifically your example is a special form of it which also reports whether the type assertion holds. If not,
ok
will befalse
, and if the assertion holds,ok
will betrue
.This special form never panics unlike the form of:
Which if
dataObject
does not hold a value of type*entities.PassengerPayment
will panic.