首页 \ 问答 \ Lodash _.hasIntersection?(Lodash _.hasIntersection?)

Lodash _.hasIntersection?(Lodash _.hasIntersection?)

我想知道两个或多个阵列是否有共同的项目,但我不在乎这些项目是什么。 我知道lodash有_.intersection方法,但我不需要它来遍历每个数组的每个项目。 相反,我需要类似_.hasIntersection方法的东西,它会在找到第一个常见事件后停止查看数组。 洛达什有类似的东西吗?


I want to know if two or more arrays have common items, but I don't care what those items are. I know lodash has an _.intersection method, but I don't need it to run through every single item of each array. Instead, I need something like a _.hasIntersection method that will stop looking in an array once it finds the first common occurrence. Does lodash have something like that?


原文:https://stackoverflow.com/questions/29416454
更新时间:2023-06-10 09:06

最满意答案

绑定到@"allValues"意味着字典被发送-valueForKey:@"allValues"消息。 然后字典通过查找-objectForKey:@"allValues"解释它-objectForKey:@"allValues"在这种情况下不是你所追求的。

尝试绑定到@"@allValues" (有关详细信息,请参阅-[NSDictionary valueForKey:]文档)


Binding to @"allValues" means the dictionary is sent a -valueForKey:@"allValues" message. The dictionary then interprets that by looking up -objectForKey:@"allValues" which is not what you are after in this case.

Try binding to @"@allValues" instead (see the -[NSDictionary valueForKey:] docs for more details)

相关问答

更多
  • 两个问题: 将plist加载到NSDictionary中: 这是一个简单的问题,看起来你已经知道了。 plist中的全局对象是一个数组,而不是字典,所以当你将它加载到字典中时,它不知道该怎么做(不兼容类型),所以你得到一个空字典。 循环查看字典数组: 从你得到的异常,你在字典上调用'setObject:forKey:',它被初始化为一个NSDictionary,而不是一个NSMutableDictionary。 指针的类型为NSMutableDictionary,但不是内存中的实际对象。 你需要改变你的路线 ...
  • 您可以使用: let keys = jsonResult.flatMap(){ $0.0 as? String } let values = jsonResult.flatMap(){ $0.1 } You can use: let keys = jsonResult.flatMap(){ $0.0 as? String } let values = jsonResult.flatMap(){ $0.1 }
  • 它返回一种类型,因为你的两个键是相同的,尝试重命名键来分隔名称,当你键入allKeys时,与这些键相关的值将会出现 it is returning one type as both your keys are same, Try renaming the keys to separate names, and the values associated with those keys will come when u type allKeys
  • 你的JSON对象是一个包含两个字典的数组。 这就是如何获得价值观: NSDictionary* dict1= json[0]; NSString* text= dict1[@"text"]; NSString* title= dict1[@"title"]; Your JSON object is an array, containing two dictionaries. That's how to get the values: NSDictionary* dict1= json[0]; NSStri ...
  • 值可以在字典中出现多次,但不能出现在集合中。 因此返回一个数组会返回所有值,而返回一个set将只返回唯一值。 键当然必须是唯一的,所以我建议选择数组而不是set是简单的一致性。 A value can occur more than once in a dictionary but not in a set. So returning an array returns all the values, while returning a set would return only the unique val ...
  • 没有什么是错的。 NSDictionary是一个无序集合。 说“我添加它们的顺序”没有任何意义。 如果您想以特定顺序访问密钥,那么您必须在字典旁边存储数组或获取密钥,然后对它们进行排序并使用它来按顺序访问值。 Nothing is going wrong here. NSDictionary is an unordered collection. To say "the order I added them" has no meaning. If you want to access the keys in ...
  • 要转换字典,您可以使用它的方法: myArray = [[NSArray alloc] initWithArray:[myDic allValues]]; UPDATE 如果要添加dic以便检索它并使用键来检索值,请使用NSMutableArray如下所示: NSMutableArray *myArray = [[NSMutableArray alloc] init]; [myArray addObject:myDic]; 然后简单地通过使用以下方式检索dic: NSDictionary *myDic ...
  • 我想指出下面的文章:苹果公司的工程师ridiculous_fish的 “ Array ”。 可能的数组并不一定是你所期望的那么好实施的天真数组,字典也不是简单的哈希表。 他们的表现是非常间接的,取决于他们持有的对象的数量(以及他们的价值等)。 这可能不会直接影响答案,但需要考虑的事情(当然, NSDictionary性能会随着哈希函数的速度和可靠性等而变化)。 此外,如果你正在寻找一个“平衡”的测试,你将不得不寻找一种方式让两个班级尽可能接近。 您希望排除通过字典中的键访问值,因为 - 无论NSDictio ...
  • 绑定到@"allValues"意味着字典被发送-valueForKey:@"allValues"消息。 然后字典通过查找-objectForKey:@"allValues"解释它-objectForKey:@"allValues"在这种情况下不是你所追求的。 尝试绑定到@"@allValues" (有关详细信息,请参阅-[NSDictionary valueForKey:]文档) Binding to @"allValues" means the dictionary is sent a -valueFor ...
  • 我想你可以使用keysOfEntriesPassingTest 。 就像是: NSSet *keysSet = [dictionary keysOfEntriesPassingTest:^(id key, id obj, BOOL *stop) { if ([[obj objectAtIndex:0] isEqualToString:@"Samrin Ateequi"]) { return YES; ...

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)