scala - 关于 Scala 的语法
问题描述
谁能告诉我这是什么意思:
A = (rs: WrappedResultSet) => throw new IllegalStateException ("The extractor isn't specified yet.")
解决方案
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
如上面的代码所示抛出。
让我知道它是否有帮助!
推荐阅读
- bash - 如何将 > 符号作为参数传递?
- python - Django:如何过滤来自函数的值的对象?
- reactjs - 样式组件:使用时共享样式组件
命名约定 - windows - 如何使用 IDA 调试 Windows 驱动程序并使用其对应的 IDB?
- java - 从独立的 Java 应用程序访问 Websphere 数据源而不指定用户名/密码
- xamarin.forms - 如何在 Xamarin.Forms ios 中实现 UnifiedNative 广告
- javascript - 如果一个正数等于它的倒数
- ajax - 提交时不会捕获模式内的事件
- javascript - Json 对象在 IE11 中未正确获取
- state - 有没有像 Svelte 3 的 Vuex 之类的东西?