text Encontrar elemento en array

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Encontrar elemento en array相关的知识,希望对你有一定的参考价值。

https://stackoverflow.com/questions/28727845/find-an-object-in-array

Check if the element exists

if array.contains(where: {$0.name == "foo"}) {
   // it exists, do something
} else {
   //item could not be found
}
Get the element

if let foo = array.first(where: {$0.name == "foo"}) {
   // do something with foo
} else {
   // item could not be found
}
Get the element and its offset

if let foo = array.enumerated().first(where: {$0.element.name == "foo"}) {
   // do something with foo.offset and foo.element
} else {
   // item could not be found
}
Get the offset

if let fooOffset = array.index(where: {$0.name == "foo"}) {
    // do something with fooOffset
} else {
    // item could not be found
}

以上是关于text Encontrar elemento en array的主要内容,如果未能解决你的问题,请参考以下文章

text MétodogetElementById()o qual retorna o elemento que possui o atributo ID com o valor espec

sh Encontrar textoemmúltiplosarquivos

apache_conf Encontrar si palabra se encuentra al final de cadena de texto - FCC [248]

Mostrar ocultar elemento/显示隐藏元素

javascript se elemento tem outro

markdown elementos WSDL