波纹管代码:
scala> class A {
| def hi = "Hello from A"
| override def toString = getClass.getName
| }
defined class A
scala> val a = new A()
a: A = A
scala> a.toString
res10: String = A
scala> println(s"${a.toString}")
$line31.$read$$iw$$iw$A
Run Code Online (Sandbox Code Playgroud)
使用a.toString表达式时打印正常,而不是在使用时打印println(s"${a.toString}").问题是getClass.getName.在其他情况下,它很好用.
在此先感谢您的帮助
嗨,全世界的校长们。我正在用 Java 进行反应式编程。我是一名 java/grails/react 开发人员,但第一步是使用 Spring Boot 进行反应式编程,在这种情况下是版本 2 M7。在接下来的代码中:
@GetMapping(API_BASE_PATH + "/flux4")
public String flux4() {
StringBuilder sb = new StringBuilder();
Flux.just("alpha", "bravo", "charlie")
.map(String::toUpperCase)
.flatMap(s -> Flux.fromArray(s.split("")))
.groupBy(String::toString)
.sort(Comparator.comparing(GroupedFlux::key))
.map(group -> group.key() + " => " + group.count() + "; ")
.subscribe(sb::append);
return "flux 4: " + sb.toString();
}
Run Code Online (Sandbox Code Playgroud)
我打印了 group.key() 但是如何打印 group.count() ?
欢迎任何帮助
干杯
胡安
我正在遵循Scala中的类型级编程.
我得到了以下代码
sealed trait Bool {
type && [b <: Bool] <: Bool
type || [b <: Bool] <: Bool
type IfThenElse[B, T <: B, F <: B] <: B
}
object True extends Bool {
type && [B <: Bool] = B
type || [B <: Bool] = True.type
type IfThenElse[B, T <: B, F <: B] = T
}
object False extends Bool {
type && [B <: Bool] = False.type
type || [B <: Bool] …Run Code Online (Sandbox Code Playgroud)