types.Array.hasvalue
Method on every
arrayReports whether any element equals value.
The binding carries no declaration string, so the VM cannot report parameter names. The names above are from this page; the types and attributes still come from the VM. The VM also cannot tell an optional parameter from a variadic tail here, so read the brackets and any trailing
... from the prose below, not from the signature.Parameters
value | any | the value to look for |
Return value
true if some element equals value, false otherwise.
Notes
This is contains registered under a second name; the two are the same function and behave identically, including the raw, identity-based equality described there.
Example
let a = [1, 2, 3];
println("a.hasvalue(2) =", a.hasvalue(2), "a.hasvalue(9) =", a.hasvalue(9));
println("a.hasvalue(2) == a.contains(2):", a.hasvalue(2) == a.contains(2)); // hasvalue and contains share one implementationOutput:
a.hasvalue(2) = true a.hasvalue(9) = false
a.hasvalue(2) == a.contains(2): trueSee also
contains | Reports whether any element equals value. |
indexof | Finds the index of the first element that equals value. |
| array | class index |