jweinst1
5/3/2016 - 7:00 AM

using interface return type in go as any type

using interface return type in go as any type

package main

import (
	"fmt"
	"reflect"
)
//general return type for go
//add ints together
func addints(first, second int) interface{} {
	return first + second
}

func concatstrs(first, second string) interface{} {
	return first + second
}

func main() {
  fmt.Println(addints(9, 9));
  fmt.Println(reflect.TypeOf(addints(8, 8)))
  fmt.Println(reflect.TypeOf(concatstrs("hello ", "world")))
}
/*18
int
string*/