在Go中,如何编写多行语句? [英] In Go, how to write a multi-line statement?
本文介绍了在Go中,如何编写多行语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
a = b + c + s \
+ x + y
或简单地说,
a = b + c + s +
x + y
Go语言可以这样做吗?谢谢
解决方案
当然,只需在最后放置一个运算符,例如:
a = b + c + s +
x + y
另外请注意,在操作员面前不可能打破这条线。以下代码为无效:
a = b + c + s
+ x + y
In python, we use backslash to indicate that the current statement continues to next line
for example,
a = b + c + s \
+ x + y
or simply,
a = b + c + s +
x + y
Is it possible to do that in Go language? Thanks
解决方案
Sure it is, just put an operator at the end, for example:
a = b + c + s +
x + y
Also note that it's not possible to break the line before the operator. The following code is invalid:
a = b + c + s
+ x + y
The rule is described here and in the specification.
这篇关于在Go中,如何编写多行语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文