golang typeassertion.go

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了golang typeassertion.go相关的知识,希望对你有一定的参考价值。

package main
//go program to implement a portable VM

import (
    "fmt"
)

func Add(first, second interface{}) interface{} {
	return first.(int) + second.(int)
}



func main(){
	fmt.Println(Add(5, 6))
	//prints 11
}
//generic types using assertion

Golang 学习之路

Golang基础

Golang基础之包概念
Golang基础之数据类型
Golang基础之流程控制
Golang基础之数组
Golang基础之切片
Golang基础之map
Golang基础之函数
Golang基础之指针
Golang基础之结构体
Golang基础之接口

Golang Web开发

Golang 其它

算法

以上是关于golang typeassertion.go的主要内容,如果未能解决你的问题,请参考以下文章