Language Design: Naming Conventions

Part 3: Lookup

Published on 2022-06-07. Last updated on 2022-07-26
Name Example Explanation
List(12.3, 45.6)(0) --> Some(12.3) Map("key", "val")("key") --> Some("val")
  • retrieves the value at the given index/key
at(idx) Array(12.3, 45.6).at(1) --> Some(Ref(arr, 1))
  • returns a reference to the given position in the array
contains(val) List(1.0, -0.0, NaN).contains(0.0) --> true List(1.0, -0.0, NaN).contains(NaN) --> true Map("key", "val").contains("key") --> true
  • checks whether container contains a value, as determined by either equality (==) or identity (===)
includes(val) List(1.0, -0.0, NaN).includes(0.0) --> true List(1.0, -0.0, NaN).includes(NaN) --> false Map("key", "val").includes("key") --> true
  • checks whether container includes a value, as determined by equality (==)
has(val) List(1.0, -0.0, NaN).has(0.0) --> false List(1.0, -0.0, NaN).has(NaN) --> true Map("key", "val").includes("key") --> true
  • checks whether container has a value, as determined by identity (===)
findFirst(pred) List(3, 1, 2, 3).findFirst(_ < 3) --> Some(1)
  • find first value in container that satisfies the provided predicate
findLast(pred) List(3, 1, 2, 3).findLast(_ < 3) --> Some(2)
  • find last value in container that satisfies the provided predicate