Switch cases evaluate cases from top to bottom, stopping when a case succeeds.

(For example,

switch i {
case 0:
case f():
}

does not call f if i==0.)

Note: Time in the Go playground always appears to start at 2009-11-10 23:00:00 UTC, a value whose significance is left as an exercise for the reader.

package main  

import (
"fmt"
"time"
) func f(num *int) int{
(*num) = (*num) +
return (*num);
}
func main() {
num :=
total :=
switch total {
case f(&num):
fmt.Println(num)
case f(&num):
fmt.Println(num)
case f(&num):
fmt.Println(num)
}
fmt.Println("When's Saturday?")
today := time.Now().Weekday()
switch time.Saturday {
case today + :
fmt.Println("Today.")
case today + :
fmt.Println("Tomorrow.")
case today + :
fmt.Println("In tow days.")
default:
fmt.Println("Too far away.")
}
}

case中的语句可以是返回值的语句

最新文章

  1. AbpKernelModule
  2. Total Commander 集成、调用 Beyond Compare比较文件
  3. Deep learning:四十三(用Hessian Free方法训练Deep Network)
  4. vue.js 简单入门
  5. mysql中Timestamp,time,datetime 区别
  6. 利用windbg探索进程和进程上下文
  7. 记一次SortedDictionary的不当使用
  8. HTTP 错误 500.19 - Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效。
  9. sql 时间向减函数
  10. 【mongodb】 需求
  11. POJ1269+直线相交
  12. WCF宿主实践入门
  13. 初探swift语言的学习笔记(闭包 - 匿名函数或block块代码)
  14. WebForm 控件(二)
  15. Mirantis MCP 1.0:OpenStack 和 Kubernetes 整合的第一步
  16. SELECT与SET对变量赋值
  17. Ignatius and the Princess IV(乱搞一发竟然过了)
  18. LOJ6002 - 「网络流 24 题」最小路径覆盖
  19. java设计模式:面向对象设计的7个原则
  20. Spring Cloud、Spring Boot与Docker 学习资料汇总

热门文章

  1. Java 方法覆盖和方法重载
  2. mybatis的知识点总结
  3. [译]再次对比TCP与UDP
  4. Oracle命令(一):Oracle登录命令
  5. 1210. Kind Spirits(spfa)
  6. POJ2892Tunnel Warfare (线段树)
  7. Java [leetcode 9] Palindrome Number
  8. date 获取昨天日期
  9. T-SQL查询进阶—理解SQL Server中的锁
  10. NGINX(五)模块