Chinaunix首页 | 论坛 | 博客
  • 博客访问: 30687
  • 博文数量: 11
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2014-10-19 21:19
文章分类
文章存档

2015年(2)

2014年(9)

我的朋友

分类: 敏捷开发

2014-11-24 21:22:07


点击(此处)折叠或打开

  1. // IfElse
  2. package main

  3. import (
  4.     "fmt"
  5. )

  6. func main() {
  7.     if 7%2 == 0 {
  8.         fmt.Println("7 is even")
  9.     } else {
  10.         fmt.Println("7 is odd")
  11.     }
  12.     //You can have an if statement without an else.
  13.     if 8%4 == 0 {
  14.         fmt.Println("8 is divisible by 4")
  15.     }
  16.     //A statement can precede conditionals; any variables declared in this statement are available in all branches.
  17.     if num := 9; num < 0 {
  18.         fmt.Println(num, "is negative")
  19.     } else if num < 10 {
  20.         fmt.Println(num, "has 1 digit")
  21.     } else {
  22.         fmt.Println(num, "has multiple digits")
  23.     }
  24. }
转自
阅读(986) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~