From 68110b2250487599e44aa9daa6db924535c2e6d1 Mon Sep 17 00:00:00 2001 From: Iker Date: Thu, 29 Aug 2024 23:43:49 -0500 Subject: [PATCH 1/6] Added the .md --- content/swift/concepts/dictionaries/terms/contains/contains.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 content/swift/concepts/dictionaries/terms/contains/contains.md diff --git a/content/swift/concepts/dictionaries/terms/contains/contains.md b/content/swift/concepts/dictionaries/terms/contains/contains.md new file mode 100644 index 00000000000..e69de29bb2d From a884d019a974c452fc29b4789f2dedb39a8d9a5b Mon Sep 17 00:00:00 2001 From: Iker Date: Fri, 30 Aug 2024 10:56:58 -0500 Subject: [PATCH 2/6] Entry written --- .../swift/concepts/dictionaries/terms/contains/contains.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/swift/concepts/dictionaries/terms/contains/contains.md b/content/swift/concepts/dictionaries/terms/contains/contains.md index e69de29bb2d..f6fe876d863 100644 --- a/content/swift/concepts/dictionaries/terms/contains/contains.md +++ b/content/swift/concepts/dictionaries/terms/contains/contains.md @@ -0,0 +1,5 @@ +## Codebyte Example + +```codebyte/javascript +console.log('Hello, World!'); +```s \ No newline at end of file From f9b226ca65f6a4dcfec562205415fb3c560d90aa Mon Sep 17 00:00:00 2001 From: Iker Date: Fri, 30 Aug 2024 12:11:54 -0500 Subject: [PATCH 3/6] correction --- .../swift/concepts/dictionaries/terms/contains/contains.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/content/swift/concepts/dictionaries/terms/contains/contains.md b/content/swift/concepts/dictionaries/terms/contains/contains.md index f6fe876d863..e69de29bb2d 100644 --- a/content/swift/concepts/dictionaries/terms/contains/contains.md +++ b/content/swift/concepts/dictionaries/terms/contains/contains.md @@ -1,5 +0,0 @@ -## Codebyte Example - -```codebyte/javascript -console.log('Hello, World!'); -```s \ No newline at end of file From 3605d23f0db7f3dc303c571556238841af9fb662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iker=20V=C3=A9lez?= <168359086+Iker1211@users.noreply.github.com> Date: Fri, 30 Aug 2024 17:19:26 +0000 Subject: [PATCH 4/6] correction 2 --- .../dictionaries/terms/contains/contains.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/content/swift/concepts/dictionaries/terms/contains/contains.md b/content/swift/concepts/dictionaries/terms/contains/contains.md index e69de29bb2d..10360928fbb 100644 --- a/content/swift/concepts/dictionaries/terms/contains/contains.md +++ b/content/swift/concepts/dictionaries/terms/contains/contains.md @@ -0,0 +1,36 @@ +--- +Title: '.contains' +Description: 'Returns a Boolean value indicating whether the sequence contains the given element.' +Subjects: + - 'Mobile Development' + - 'Computer Science' +Tags: + - 'Dictionaries' + - 'Properties' +CatalogContent: + - 'learn-swift' + - 'paths/build-ios-apps-with-swiftui' +--- + +The **`.contains()`** method returns true if an array contains a specified element, false otherwise. + +## Syntax + +```pseudo +arrayName.contains(element) +``` + +## Example + +In the example below, `.contains()` is checking to see if a favorite actor is in an array storing a movie’s cast. + +```swift +let cast = ["Vivien", "Marlon", "Kim", "Karl"] +print(cast.contains("Marlon")) +``` + +This example results in the following output: + +```shell +// Prints "true" +``` From 4b41c1a963b747b011843396c5551a2ce21754e1 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Sun, 1 Sep 2024 23:18:40 +0530 Subject: [PATCH 5/6] Update contains.md minor changes --- .../dictionaries/terms/contains/contains.md | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/content/swift/concepts/dictionaries/terms/contains/contains.md b/content/swift/concepts/dictionaries/terms/contains/contains.md index 10360928fbb..a99b0b9a2c1 100644 --- a/content/swift/concepts/dictionaries/terms/contains/contains.md +++ b/content/swift/concepts/dictionaries/terms/contains/contains.md @@ -1,28 +1,38 @@ --- -Title: '.contains' +Title: '.contains()' Description: 'Returns a Boolean value indicating whether the sequence contains the given element.' Subjects: - - 'Mobile Development' - 'Computer Science' + - 'Mobile Development' Tags: - - 'Dictionaries' + - 'Dictionary' - 'Properties' CatalogContent: - 'learn-swift' - 'paths/build-ios-apps-with-swiftui' --- -The **`.contains()`** method returns true if an array contains a specified element, false otherwise. +The **`.contains()`** method returns `true` if an array contains a specified element, `false` otherwise. ## Syntax ```pseudo -arrayName.contains(element) +dictionaryInstance.contains(element) +``` + +- `element`: The item to check for in the array. It returns `true` if the item is present, and `false` otherwise. + +To check if a dictionary contains a specific key-value pair, the following is used: + +```pseudo +dictionaryInstance.contains{check} ``` +- `check`: A closure that takes a key-value pair `(key, value)` and returns `true` if the pair satisfies the specified condition, and `false` otherwise. + ## Example -In the example below, `.contains()` is checking to see if a favorite actor is in an array storing a movie’s cast. +In the example below, `.contains()` is checking if a particular actor is in an array storing a movie’s cast: ```swift let cast = ["Vivien", "Marlon", "Kim", "Karl"] @@ -32,5 +42,5 @@ print(cast.contains("Marlon")) This example results in the following output: ```shell -// Prints "true" +true ``` From d8ba6b0be4745be16419cf58ba05c60d9162d0e3 Mon Sep 17 00:00:00 2001 From: Daksha Deep Date: Mon, 2 Sep 2024 08:01:35 +0530 Subject: [PATCH 6/6] Minor changes --- content/swift/concepts/dictionaries/terms/contains/contains.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/swift/concepts/dictionaries/terms/contains/contains.md b/content/swift/concepts/dictionaries/terms/contains/contains.md index a99b0b9a2c1..d6b102e9db3 100644 --- a/content/swift/concepts/dictionaries/terms/contains/contains.md +++ b/content/swift/concepts/dictionaries/terms/contains/contains.md @@ -7,12 +7,13 @@ Subjects: Tags: - 'Dictionary' - 'Properties' + - 'Arrays' CatalogContent: - 'learn-swift' - 'paths/build-ios-apps-with-swiftui' --- -The **`.contains()`** method returns `true` if an array contains a specified element, `false` otherwise. +The **`.contains()`** method returns `true` if an array contains a specified element, and `false` otherwise. ## Syntax