On Mon, Feb 5, 2018 at 1:48 PM l vic <[email protected]> wrote:

> Working on the package that should handle multiple data types. I started
with using empty interfaces

Probably not a good idea.

> but got stuck when it come to comparing empty interface values, seems
it's possible to get empty interface type, but not value
> Is there a working pattern to use in this case, aside of using
reflection?

if you need to compare values of different types stored in `interface{}`
typed values, you can do that directly: expr1 == expr2. The result is true
if both dynamic types are equal and the values are comparable and equal.

But maybe this problem calls for using

type Equaler interface{
        Equal(Equaler) bool
}

instead of `interface{}`.

-- 

-j

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to