在 Scala 中迭代两个对象序列,如果满足条件则返回 true

问题描述 投票:0回答:1

我有两个对象序列 Seq[A] 和 Seq[B]。 Seq[A] 是一个对象列表,具有这种形式

case class A(type: String,
             label: String,
             code: String)

Seq[B] 是一个规则列表,告诉我一对(键,正则表达式)

case class B(key: String,
             regex: String)

我需要检查第一个列表中的元素是否与第二个列表中的某个键匹配,然后

type
必须与相应的
code
 匹配
    

scala sequence
1个回答
1
投票
regex

filter
map
函数的组合来解决此问题。这是检查所描述的标准的方法:
exists

© www.soinside.com 2019 - 2024. All rights reserved.