MCPcopy Index your code
hub / github.com/Effect-TS/effect / unsafeLast

Function unsafeLast

packages/effect/src/List.ts:953–964  ·  view source on GitHub ↗
(self: List<A>)

Source from the content-addressed store, hash-verified

951 * @category unsafe
952 */
953export const unsafeLast = <A>(self: List<A>): A => {
954 if (isNil(self)) {
955 throw new Error(getExpectedListToBeNonEmptyErrorMessage)
956 }
957 let these = self
958 let scout = self.tail
959 while (!isNil(scout)) {
960 these = scout
961 scout = scout.tail
962 }
963 return these.head
964}
965
966/**
967 * Unsafely returns the tail of the specified `List`.

Callers 1

lastFunction · 0.70

Calls 1

isNilFunction · 0.85

Tested by

no test coverage detected