Skip to content

Commit cfd0f30

Browse files
authored
Document String contains method (#6320) [ci fast]
--------- Signed-off-by: Ben Sherman <[email protected]>
1 parent f73f87b commit cfd0f30

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

docs/reference/stdlib-types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,6 @@ The following operations are supported for strings:
805805
`[] : (String, int) -> char`
806806
: Given a string and an index, returns the character at the given index in the string.
807807

808-
`in, !in : (String, String) -> boolean`
809-
: Given a substring and a string, returns `true` if the substring occurs anywhere in the string (or not).
810-
811808
`~ : (String) -> Pattern`
812809
: Creates a regular expression from a string.
813810
: See [Pattern](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html) in the Java standard library for more information.
@@ -821,6 +818,9 @@ The following operations are supported for strings:
821818

822819
The following methods are available for a string:
823820

821+
`contains( str: String ) -> boolean`
822+
: Returns `true` if the given substring occurs anywhere in the string.
823+
824824
`endsWith( suffix: String ) -> boolean`
825825
: Returns `true` if the string ends with the given suffix.
826826

docs/script.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ assert !true == false // logical NOT
152152
The `in` and `!in` operators can be used to test *membership*, i.e. whether a collection contains a value:
153153

154154
```nextflow
155-
assert 'lo wo' in 'Hello world!'
156155
assert 2 in [1, 2, 3]
156+
assert 'a' in [a: 1, b: 2, c: 3]
157157
```
158158

159159
Arithmetic operators can be used to do math:

modules/nf-lang/src/main/java/nextflow/script/types/shim/String.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
@ShimType(java.lang.String.class)
2626
public interface String {
2727

28+
@Description("""
29+
Returns `true` if the given substring occurs anywhere in the string.
30+
""")
31+
boolean contains(String str);
32+
2833
@Description("""
2934
Returns `true` if the string ends with the given suffix.
3035
""")

0 commit comments

Comments
 (0)