【发布时间】:2020-06-05 08:59:54
【问题描述】:
我是函数式编程的新手。我想为过滤器链接多个谓词。
假设我有想要过滤的名称列表...
val names = List("cat","dog","elephant")
//Currently I am doing like this, this is not dynamic,The list of name will come dynamically
objects.filterSubjects(string => {
string.endsWith("cat") || string.endsWith("dog") || string.endsWith("elephant")
})
如何使上面的行动态化,这样我就不用写了。我想根据用户提供的名字列表来创建它。
【问题讨论】:
标签: scala functional-programming predicate