首页 > 解决方案 > 关于 Scala 的语法

问题描述

问题图片

谁能告诉我这是什么意思:

A = (rs: WrappedResultSet) => throw new IllegalStateException ("The extractor isn't specified yet.")

标签: scala

解决方案


def fun[A](extractor: WrappedResultSet => A = (rs: WrappedResultSet) => throw new IllegalStateException("The extractor isn't specified yet.")): A 

这意味着该方法fun采用泛型类型参数A和一个称为类型提取器的函数WrappedResultSet => A。如果没有 的值extractor被传递给fun,则 fun 使用默认行为,即IllegalStateException如上面的代码所示抛出。

让我知道它是否有帮助!


推荐阅读