@mikuroxina/mini-fn
    Preparing search index...

    Function last

    • Gets the last element of the list. If the list is infinite, it hangs forever.

      Type Parameters

      • T

      Parameters

      Returns Option.Option<T>

      The last element of list if exists.

      Examples

      expect(last(empty())).toStrictEqual(Option.none());
      expect(last(fromString("hoge"))).toStrictEqual(Option.some("e"));

      const list = singleton(42);
      expect(last(list)).toStrictEqual(Option.some(42));
      expect(last(list.rest())).toStrictEqual(Option.none());