func Foo(in interface{}) { val, ok := in.(someTypeOrInterface) if !ok { // TODO HANDLE ERROR } ... }
Wow, this is so much more readable /s On Thursday, August 24, 2017 at 6:14:58 PM UTC+3, JuciĆ Andrade wrote: > > A lot of people like Go because code is very readable even for beginners. > > func f(x, y int) > > f is a function that receives x and y as int parameters, returning > nothing. Simple enough. > > func f(x, y int) int > > f is a function that receives x and y as int parameters, returning yet > another int. Fine. > > func f(x, y int) (z int, err error) > > f is a function that receives x and y as int parameters, returning two > values: a first int, that we name z and an error named err. A little bit > weird, but ok. > > func (r MyType) f(x, y int) (z int, err error) > > f is a method for a value of type MyType, henceforth named r, that > receives x and y as int parameters, returning two values: a first int, that > we name z and an error named err. Definitely not so simple. > > <genType1, genType2> func (r genType1) f(x, y genType2) (z getType2, err > error) > > You must be kidding. STOP RIGHT THERE! > > -- 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, visit https://groups.google.com/d/optout.