Apache Zeppelin 中的多行字符串
Multiple line strings in Apache Zeppelin
我有一个很长的字符串,必须分成多行。我怎样才能在飞艇中做到这一点?
错误是error: missing argument list for method + in class String
:
这里是更完整的错误信息:
<console>:14: error: missing argument list for method + in class String
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `$plus _` or `$plus(_)` instead of `$plus`.
val q = "select count(distinct productId),count(distinct date),count(distinct instock_inStockPercent), count(distinct instock_totalOnHand)," +
在 Scala 中(使用 Apache Zeppelin 以及其他方式),您可以通过将表达式括在括号中来编写覆盖多行的表达式:
val text = ("line 1"
+ "line 2")
使用括号
正如忒修斯所说。一种方法是括号。
val text = ("line 1" +
"line 2")
实际上,所有按语义打断的多行语句都可以用括号括起来。喜欢。
(object.function1()
.function2())
使用"""
对于多行字符串。我们可以像这样使用"""
,
val s = """line 1
line2
line3"""
line2
和 line3
之前的前导 space 将被包括在内。如果我们不想让前导 spaces。我们可以这样使用。
val s = """line 1
|line2
|line3""".stripMargin
或使用不同的条带字符
val s = """line 1
$line2
$line3""".stripMargin('$')
我有一个很长的字符串,必须分成多行。我怎样才能在飞艇中做到这一点?
错误是error: missing argument list for method + in class String
:
这里是更完整的错误信息:
<console>:14: error: missing argument list for method + in class String
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `$plus _` or `$plus(_)` instead of `$plus`.
val q = "select count(distinct productId),count(distinct date),count(distinct instock_inStockPercent), count(distinct instock_totalOnHand)," +
在 Scala 中(使用 Apache Zeppelin 以及其他方式),您可以通过将表达式括在括号中来编写覆盖多行的表达式:
val text = ("line 1"
+ "line 2")
使用括号
正如忒修斯所说。一种方法是括号。
val text = ("line 1" +
"line 2")
实际上,所有按语义打断的多行语句都可以用括号括起来。喜欢。
(object.function1()
.function2())
使用"""
对于多行字符串。我们可以像这样使用"""
,
val s = """line 1
line2
line3"""
line2
和 line3
之前的前导 space 将被包括在内。如果我们不想让前导 spaces。我们可以这样使用。
val s = """line 1
|line2
|line3""".stripMargin
或使用不同的条带字符
val s = """line 1
$line2
$line3""".stripMargin('$')