Switch without a condition is the same as switch true.

This construct can be a clean way to write long if-then-else chains.

package main 

import (
"fmt"
"time"
) func main() {
t := time.Now()
switch {
case t.Hour() < :
fmt.Println("Good morning!")
case t.Hour() < :
fmt.Println("Good afternoon")
default:
fmt.Println("Good evening.")
}
}

A Tour of Go Switch with no condition的更多相关文章

  1. A Tour of Go Switch evaluation order

    Switch cases evaluate cases from top to bottom, stopping when a case succeeds. (For example, switch ...

  2. A Tour of Go Switch

    You probably knew what switch was going to look like. A case body breaks automatically, unless it en ...

  3. UVALive 6912 Prime Switch 状压DP

    Prime Switch 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8& ...

  4. UVALive 6912 Prime Switch 暴力枚举+贪心

    题目链接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show ...

  5. Golang 学习资料

    资料 1.How to Write Go Code https://golang.org/doc/code.html 2.A Tour of Go https://tour.golang.org/li ...

  6. Go Flow Control

    [Go Flow Control] 1.for没有(),必须有{}. 2.for的前后表达式可以为空. 3.没有while,for即是while. 4.无穷循环. 5.if没有(),必须有{}. 6. ...

  7. JS源码(条件的判定,循环,数组,函数,对象)整理摘录

    --- title: JS学习笔记-从条件判断语句到对象创建 date: 2016-04-28 21:31:13 tags: [javascript,front-end] ---JS学习笔记——整理自 ...

  8. JAVA语言中冒号的用法

    近来由于本人要介入android平台的开发,所以就买了本JAVA语言的书学习.学习一段时间来,我的感觉是谭浩强就是厉害,编写的<C编程语言>系列丛书不愧是经典.书中对C语言的介绍既系统又全 ...

  9. javascript中的分支判断与循环

    分支判断与循环 分支结构 单一选择结构(if) 二路选择结构(if/else) 内联三元运算符 ?: 多路选择结构(switch) var condition = true; if (conditio ...

随机推荐

  1. PowerDesigner将name自动添加到Comment注释的方法 VB代码

    Option Explicit ValidationMode = True InteractiveMode = im_Batch Dim mdl ' the current model ' get t ...

  2. 服务器部署_linux下部署jprofiler简单备忘

    1.windows安装jprofiler 2.linux下安装jprofiler服务端,记好安装路径.假设是安装在/ex/bin/下 3. 配置tomcat的启动sh文件,在后面加入以下参数:  -a ...

  3. *MySQL卸载之后无法重装,卡在Apply security settings:Error Nr.1045

  4. 【HDOJ】4297 One and One Story

    综合性很强的题目.存在环,可以用tarjan处理,然后需要求LCA.并查集+RMQ可以搞.非常不错的题目. /* 4297 */ #include <iostream> #include ...

  5. Vim cscope

    /********************************************************************** * Vim cscope * 说明: * 之前使用Vim ...

  6. 多线程程序设计学习(12)Thread-soecific storage pattern

    Thread-Specific-Storage[线程保管箱] 一:Thread-Specific Storage的参与者--->记录日志的线程(ClientThread)--->负责获取不 ...

  7. 【js】获得项目路径

    var curWwwPath=window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathNam ...

  8. WCF HTTPS配置

    昨天需要把做好的一个wcf服务发布到服务器站点下的一个虚拟目录中发布过程遇到了一个问题:服务器上的环境是https,因此需要多对配置文件修改于是在网上找啊找,遇到一个问题找一个问题,可是问题依然没解决 ...

  9. Oracle 参数化更新数据时报错:Oracle ORA-01722: 无效数字

    报错:Oracle ORA-01722: 无效数字 看了一篇博客,据说是参数与列名不能一致,改过之后还是报一样的错误:Oracle ORA-01722: 无效数字 ,后来试了一下,不是参数名必须不一样 ...

  10. Project Euler 26 Reciprocal cycles

    题意:求1到n中所有数的倒数中循环小数循环体最长的数 解法:如果一个数的质因子只有2和5,那么这个数的倒数一定不是一个循环小数.如果一个数含有质因子2或5,那么它的循环体和去掉质因子2和5之后的数的循 ...