docs: fix index-of api reference

This commit is contained in:
Hugo Caillard
2022-12-22 19:03:28 +01:00
parent 277fa1e943
commit af03bfbb31

View File

@@ -1134,10 +1134,10 @@ In Clarity1, `element-at` must be used (without the `?`). The `?` is added in Cl
const INDEX_OF_API: SpecialAPI = SpecialAPI {
input_type: "sequence_A, A",
snippet: "index-of ${1:sequence} ${2:item}",
snippet: "index-of? ${1:sequence} ${2:item}",
output_type: "(optional uint)",
signature: "(index-of sequence item)",
description: "The `index-of` function returns the first index at which `item` can be
signature: "(index-of? sequence item)",
description: "The `index-of?` function returns the first index at which `item` can be
found, using `is-eq` checks, in the provided sequence.
Applicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`,
for which the corresponding element types are, respectively, `A`, `(buff 1)`, `(string-ascii 1)` and `(string-utf8 1)`.
@@ -1146,11 +1146,11 @@ supplied), this function returns `none`.
In Clarity1, `index-of` must be used (without the `?`). The `?` is added in Clarity2 for consistency -- built-ins that return responses or optionals end in `?`. The Clarity1 spelling is left as an alias in Clarity2 for backwards compatibility.
",
example: r#"
(index-of "blockstack" "b") ;; Returns (some u0)
(index-of "blockstack" "k") ;; Returns (some u4)
(index-of "blockstack" "") ;; Returns none
(index-of (list 1 2 3 4 5) 6) ;; Returns none
(index-of 0xfb01 0x01) ;; Returns (some u1)
(index-of? "blockstack" "b") ;; Returns (some u0)
(index-of? "blockstack" "k") ;; Returns (some u4)
(index-of? "blockstack" "") ;; Returns none
(index-of? (list 1 2 3 4 5) 6) ;; Returns none
(index-of? 0xfb01 0x01) ;; Returns (some u1)
"#,
};