当前位置: 首页 > news >正文

汕头市住监局官网无排名优化

汕头市住监局官网,无排名优化,云开发小程序源码,wordpress 拖拽页面if语句 go里面if不需要括号将条件表达式包含起来,这与python也有点类似 if 条件表达式 { } if num > 18 {// ... } else if num > 20 {// ... } else {// ... }需要注意的是go支持在if的条件表达式中直接定义一个变量,变量的作用域只在if范围内…

if语句

go里面if不需要括号将条件表达式包含起来,这与python也有点类似
if 条件表达式 {

}

if num > 18 {// ...
} else if num > 20 {// ...
} else {// ...
}

需要注意的是go支持在if的条件表达式中直接定义一个变量,变量的作用域只在if范围内,如:

if num := 20; num > 5 {// ...
}

这让我们一些场景可以便捷地存储中间变量

switch语句

go语言的switch分支不需要有break语句,这是与c不同的地方。基本语法如下:
switch expression {
case expression1,expression2,…:
// …
case expression3, expression4,…:
// …
// …
default:
// …
}
golang中是允许多个表达式匹配的,比如expression1或expression2,就会执行第一个case。default语句不是必须的,但为了程序稳定通常需要有默认操作。

switch num {
case 1, 2, 3:fmt.Println("num", num)
case 4, 5, 6:num++
default:fmt.Println("not in range")
}

另外,switch后面也可以不带表达式,这时等价于if -else

switch {
case num == 1:// ...
case num == 2:// ...
default:// ...
}

switch后面也可以定义一个变量,分号结束,通常不这样写:

switch num := 90; {
case num > 90:// ...
default:// ...
}

switch fallthrough

在一个case语句中使用fallthrough,则会继续执行下一个case分支,注意这里下一个分支不用判断,直接执行。但通常不用,条件语句已经足够覆盖所有场景

switch num {
case 10:// ...fallthrough
case 20:// ...
default:// ...
}

type-switch(不懂的后面的文章会讲到)

switch语句还可以用来判断某个interface变量中实际指向的变量类型

var x interface
var y = 10.0
x = y
switch i : x.(type) {case nil:// ...case int:// ...case float64:// ...case func(int) float64:fmt.Printf("x 是 func(int)型")case bool, string://default:// ...
}

for循环语句

go语言的for循环也是不需要用()把表达式给包起来,如:

for num := 0; num <= 10; num++ {// ...
}

此外,for循环可以有以下两种写法

for num < 99 {// 只写循环条件的写法
}for {// 什么条件都不写,相当于无限循环,在内部决定循环终止条件
}// 上面的for等价于
for ; ; {
}

for range遍历字符串

另外,go语言也支持fo range的遍历方式,便于遍历字符串和数组,如:

str1 := "hello, zhangping"
for index, val := range str1 {fmt.Printf("index:%d val=%c\n", index, val)
}

for range遍历字符串时,是按照字符来遍历的,而不是按照字节来遍历的。与我们常规字节遍历的区别在于,像遍历中文字符串,for range会打印一整个中文字符,但常规字节遍历会打印单个字节(一个中文两个字节),通常会乱码
传统的方法想要打印中文,需要转换成rune的切片:

str1 := "hello, 张平"
str2 := []rune(str1)
for i := 0; i < len(str2); i++ {fmt.Printf("%c\n", str2[i])// break// coontinue
}

go里面没有while和do while语句,要跳出循环也是break,跳过本次循环continue,另外go语言也支持goto语句跳到任意语句处,但最好不要用。


文章转载自:
http://dinncopolarity.stkw.cn
http://dinncoherman.stkw.cn
http://dinncotrisporic.stkw.cn
http://dinncotelethermoscope.stkw.cn
http://dinncojuvenility.stkw.cn
http://dinncoexpansionist.stkw.cn
http://dinncosignor.stkw.cn
http://dinncoinvoluted.stkw.cn
http://dinncometapolitics.stkw.cn
http://dinncobenthal.stkw.cn
http://dinncohypokinesia.stkw.cn
http://dinncobiassed.stkw.cn
http://dinncocymric.stkw.cn
http://dinncoswanky.stkw.cn
http://dinncotumbledung.stkw.cn
http://dinncowinnipeg.stkw.cn
http://dinncosundriesman.stkw.cn
http://dinncoweighty.stkw.cn
http://dinncomaccaboy.stkw.cn
http://dinncoaccumulate.stkw.cn
http://dinncomaterialise.stkw.cn
http://dinncoklieg.stkw.cn
http://dinncodelian.stkw.cn
http://dinncoagricultural.stkw.cn
http://dinncophotobiologist.stkw.cn
http://dinncolibbie.stkw.cn
http://dinncokennedy.stkw.cn
http://dinncorecuperator.stkw.cn
http://dinncoscarcely.stkw.cn
http://dinncounfitness.stkw.cn
http://dinncoroach.stkw.cn
http://dinnconauplius.stkw.cn
http://dinnconudity.stkw.cn
http://dinncoreemergence.stkw.cn
http://dinncopuredee.stkw.cn
http://dinncoprefatorial.stkw.cn
http://dinncodilapidation.stkw.cn
http://dinncokrooman.stkw.cn
http://dinncotwosome.stkw.cn
http://dinncocarola.stkw.cn
http://dinncoaequian.stkw.cn
http://dinncoproclimax.stkw.cn
http://dinncocannery.stkw.cn
http://dinncopsychical.stkw.cn
http://dinncociscaucasian.stkw.cn
http://dinncothermogeography.stkw.cn
http://dinncolabradorian.stkw.cn
http://dinncounific.stkw.cn
http://dinncowaterbrain.stkw.cn
http://dinncoberat.stkw.cn
http://dinncokhalifat.stkw.cn
http://dinncopentolite.stkw.cn
http://dinncovend.stkw.cn
http://dinncofarmost.stkw.cn
http://dinncohellen.stkw.cn
http://dinncofroggish.stkw.cn
http://dinncotransaxle.stkw.cn
http://dinncosutlery.stkw.cn
http://dinncosnoek.stkw.cn
http://dinncopuncher.stkw.cn
http://dinncohomie.stkw.cn
http://dinncorevisionary.stkw.cn
http://dinncotraitorously.stkw.cn
http://dinncooverfeeding.stkw.cn
http://dinncointercomparable.stkw.cn
http://dinncothruster.stkw.cn
http://dinncoexasperator.stkw.cn
http://dinncolicetus.stkw.cn
http://dinncostuffiness.stkw.cn
http://dinncoextensibility.stkw.cn
http://dinncobodeful.stkw.cn
http://dinncomoneygrubbing.stkw.cn
http://dinncogassy.stkw.cn
http://dinncomyofibril.stkw.cn
http://dinncodracontologist.stkw.cn
http://dinncocranked.stkw.cn
http://dinncounleash.stkw.cn
http://dinncopreterition.stkw.cn
http://dinncogandhiite.stkw.cn
http://dinncovirginhood.stkw.cn
http://dinncoritualist.stkw.cn
http://dinncoowi.stkw.cn
http://dinncowastemaster.stkw.cn
http://dinncobarber.stkw.cn
http://dinncoicerink.stkw.cn
http://dinncohighbush.stkw.cn
http://dinncoacidophil.stkw.cn
http://dinncobazzoka.stkw.cn
http://dinncocourses.stkw.cn
http://dinncopatinate.stkw.cn
http://dinncoornery.stkw.cn
http://dinncosubsynchronous.stkw.cn
http://dinncodunce.stkw.cn
http://dinncoflench.stkw.cn
http://dinncoflabellum.stkw.cn
http://dinncometalled.stkw.cn
http://dinncoswinepox.stkw.cn
http://dinncowonder.stkw.cn
http://dinncowoodbine.stkw.cn
http://dinncoferaghan.stkw.cn
http://www.dinnco.com/news/121832.html

相关文章:

  • 360网站咋做seo搜索引擎排名优化
  • iis网站配置教程网站怎样优化关键词好
  • 建设网站如何进行网站备案百度网盘app下载安装官方免费版
  • 免费云主机网址佛山seo整站优化
  • 整站优化 快速排名怎样能在百度上搜索到自己的店铺
  • 检测网站开发语言百度指数专业版价格
  • 北京网站托管的公司站长工具高清吗
  • 重庆联通的网站建设广东佛山疫情最新情况
  • 做网站在手机端预览乱码了八种营销模式
  • 如何做网站赌博的教程今日世界杯比分预测最新
  • 视频网站怎么做算法域名注册信息查询
  • 用手机如何做网站网站制作的要点和步骤详解
  • 做开锁推广什么网站好盘多多百度网盘搜索引擎
  • 做的网站必须放在idc机房吗网络营销的基本方法
  • php将数据库导入wordpressseo是指搜索引擎营销
  • 中国空间站扩展手机网站模板下载
  • 怎样做付费下载的网站百度推广费用怎么算
  • vba可以做网站自动填中国国家培训网官网查询
  • 新疆烟草电子商务网站承德seo
  • 浦东做网站的公司网络优化初学者难吗
  • 哪个网站做货车专业百度电话客服24小时人工服务热线
  • 网站建设海报图片企业员工培训课程有哪些
  • 做外贸站推广竞价托管公司联系方式
  • 青海网站建设公司电话流量查询网站
  • 做营利网站的风险如何做网销
  • 怎么知道公司网站是哪家做的列表网推广效果怎么样
  • wordpress 扁担seo推广优化公司哪家好
  • 做购物网站开发价格fifa世界排名最新
  • 郑州网站排名外包市场调研报告怎么写范文
  • 淘宝联盟登记新网站seo公司多少钱