我有一个通过 collect 构建的数组。
@a = Relation.where(part: "v04")
@relations = @a.collect {|x| x.car}
构建..
=> ["f03", "f04"]
@a = Relation.where(part: "v03")
@relations = @a.collect {|x| x.car}
构建..
=> ["f01", "f03"]
我想要的是添加collect,以便我可以从v03和v04构建一个数组,使其看起来像这样。
=> ["f03", "f04", "f01", "f03"]
然后只保留唯一值,使其看起来像这样。
=> ["f03", "f04", "f01"]
去掉f03,因为它被列两次。