Selaa lähdekoodia

indexOf() documentation

Vladislav Folts 10 vuotta sitten
vanhempi
commit
249bec99bc
2 muutettua tiedostoa jossa 16 lisäystä ja 0 poistoa
  1. 15 0
      doc/wiki/eberon-array-methods.md
  2. 1 0
      doc/wiki/eberon.md

+ 15 - 0
doc/wiki/eberon-array-methods.md

@@ -0,0 +1,15 @@
+*indexOf* method is applied to array to search for specified element:
+
+    elementIndex := array.indexOf(elementValueToSearch);
+
+*indexOf* returns the index of the first element of array which value is equal to the value specified as the first argument. Its logic is equivalent to the following code:
+
+    elementIndex := 0;
+    WHILE (elementIndex < LEN(array)) & (array[elementIndex] # elementValueToSearch) DO
+        INC(elementIndex)
+    END;
+    IF elementIndex = LEN(array) THEN
+        elementIndex := -1
+    END;
+
+*indexOf* can be applied only if elements type can be used in relation operation, i.e. it cannot be applied to array of records or array of arrays.

+ 1 - 0
doc/wiki/eberon.md

@@ -7,6 +7,7 @@ Eberon basically extends original Oberon (excluding additional [restrictions](#r
 * [[Strings|eberon-strings]]
 * [[In Place Variables|eberon-in-place-variables]]
 * [[Implicit Type Narrowing|eberon-implicit-type-narrowing]]
+* [[Array indexOf() method|eberon-array-methods]]
 * [[Record fields read-only export|eberon-record-fields-read-only-export]]
 * [[Procedure call result can be denoted|eberon-procedure-call-result]]
 * Non-scalar variables (arrays and records) can be exported (forbidden in oberon for some unknown reason).