Re: [go-nuts] Mixed type array in Go

2018-01-04 Thread Tong Sun
On Thursday, January 4, 2018 at 10:59:35 AM UTC-5, Tong Sun wrote: > > That's really *comprehensive*. Thanks a million Josh! > > Hi Josh, FTA, I've archived your masterpiece as https://github.com/suntong/lang/blob/master/lang/Go/src/ds/MixedType.go and https://play.golang.org/p/lmmkTxVJht1 so

Re: [go-nuts] Mixed type array in Go

2018-01-04 Thread Tong Sun
That's really *comprehensive*. Thanks a million Josh! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options,

Re: [go-nuts] Mixed type array in Go

2018-01-04 Thread Josh Humphries
You would typically define the array type as an array of some interface that is implemented by both purchase and coupon. You can then use a type-switch or type-assertion to determine/assert the actual type at runtime, on a per element basis. If the two types do not share some interface (e.g. commo

[go-nuts] Mixed type array in Go

2018-01-04 Thread Tong Sun
I need a data struct / solution that I can store mixed data-types into an array. How to architect that? Details -- Consider the checkout point at the cashier, the checkout process receives the following string of instructions 1. purchase 2. coupon 3. purchase 4. purchase I wa