作者:傻瓜老公想你_633 | 来源:互联网 | 2023-01-07 15:58
我for comprehension
喜欢这样的:
private[helper] def myMethod(name: String, index: Long) = {
for {
result1 <- httpUtilities.getLowIndexes(index)
result2 <- myFacade.queryMaterial(result1)
result3 <- httpUtilities.someMethod(result2)
} yield result3
}
我想要的是<-
在列中对齐特殊字符,以便上面的代码转换为:
private[helper] def myMethod(name: String, index: Long) = {
for {
result1 <- httpUtilities.getLowIndexes(index)
result2 <- myFacade.queryMaterial(result1)
result3 <- httpUtilities.someMethod(result2)
} yield result3
}
我可以在设置 - >代码样式 - > Scala =>包装和大括号 - >'匹配'和'大小写'语句 - >在Intellij中对齐列'case'分支但是如何对其进行匹配案例语句<-
里面的人物for-comprehension
.
1> Mike Slinn..:
Scalafmt可以做到这一点,它可以作为IDEA插件使用,并且还可以通过许多其他方式打包.
您希望使用此align=more
功能,如此处所述.文档显示了以下对齐示例:
val x = 2 // true for assignment
val xx = 22
case object B extends A // false for `extends`
case object BB extends A
q -> 22 // true for various infix operators
qq -> 3 // and also comments!
for {
x <- List(1) // true for alignment enumerator
yy <- List(2)
} yield x ** xx
x match { // true for multiple tokens across multiple lines
case 1 => 1 -> 2 // first
case 11 => 11 -> 22 // second
// A blank line separates alignment blocks.
case `ignoreMe` => 111 -> 222
}
// Align assignments of similar type.
def name = column[String]("name")
def status = column[Int]("status")
val x = 1
val xx = 22
// Align sbt module IDs.
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"com.lihaoyi" %% "sourcecode" % "0.1.1"
)