# StructKeyExists

Tests whether a key exists in a struct and returns a boolean value

## Method Signature

```
StructKeyExists(struct=[structloose], key=[any])
```

### Arguments

| Argument | Type     | Required | Description                                     | Default |
| -------- | -------- | -------- | ----------------------------------------------- | ------- |
| `struct` | `struct` | `true`   | The struct to test                              |         |
| `key`    | `any`    | `true`   | The key within the struct to test for existence |         |

## Examples

### Check if server struct has OS key

[Run Example](https://try.boxlang.io/?code=eJwrLikqTS7xTq10rcgsLinWUChOLSpLLdJRUMovVlLQtOYCANfYCy4%3D)

```java
structKeyExists( server, "os" );

```

Result: true

### Check if server struct has OS key using member function

CF11+ calling the keyExists member function on a struct.

[Run Example](https://try.boxlang.io/?code=eJwrTi0qSy3Sy06tdK3ILC4p1lBQyi9WUtC05gIAhJEIiw%3D%3D)

```java
server.keyExists( "os" );

```

Result: true

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxdjs0KgkAUhdfOUxxmo4HgPmlRFiFBRQmth%2BGKgzoTjlEivnuOCUXczf04PxyhVS0qixV6MC853bAEr43hIfPO6d6RUbp0mKyzSSTzdLhJL1vHslDNnbMhZlGEpCBZojWwRFA5SupAL2VbC6Vh2%2BYhW6byANfpPVC3m9QA4jMkBLdaqIpjMV7PPJKFCcCzgpqx0UJg0l2dP2f80RyzgYEqSz%2BZo5m93wX%2FkTfpU0v8)

```java
animals = { 
	COW : "moo",
	PIG : "oink",
	CAT : "meow",
	BIRD : "chirp"
};
// Check to see if key exists in struct
if( StructKeyExists( animals, "snail" ) ) {
	echo( "There is a snail in 'animals'" );
}
 else {
	echo( "No snail exists in 'animals'" );
}

```

## Related

* [StructAppend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structappend)
* [StructClear](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structclear)
* [StructCopy](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structcopy)
* [StructDelete](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structdelete)
* [StructEach](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structeach)
* [StructEquals](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structequals)
* [StructEvery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structevery)
* [StructFilter](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfilter)
* [StructFind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfind)
* [StructFindKey](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfindkey)
* [StructFindValue](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structfindvalue)
* [StructGet](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structget)
* [StructGetMetadata](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structgetmetadata)
* [StructInsert](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structinsert)
* [StructIsCaseSensitive](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structiscasesensitive)
* [StructIsOrdered](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structisordered)
* [StructKeyArray](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structkeyarray)
* [StructKeyList](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structkeylist)
* [StructKeyTranslate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structkeytranslate)
* [StructMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structmap)
* [StructNew](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structnew)
* [StructNone](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structnone)
* [StructReduce](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structreduce)
* [StructSome](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structsome)
* [StructSort](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structsort)
* [StructToQueryString](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structtoquerystring)
* [StructToSorted](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structtosorted)
* [StructUpdate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structupdate)
* [StructValueArray](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structvaluearray)
