lib/linked/list_enumerable.rb
def last(n = nil)
      return empty? ? nil : list_tail unless n
      raise ArgumentError, 'n cannot be negative' if n.negative?

      return [] if n.zero? || empty?

      list_tail.take(-n)
    end
def last(n = nil)
      return empty? ? nil : list_tail unless n
      raise ArgumentError, 'n cannot be negative' if n.negative?

      return [] if n.zero? || empty?

      list_tail.take(-n)
    end
def last ( n = nil ) return empty? ? nil : list_tail unless n raise ArgumentError , 'n cannot be negative' if n . negative? return [ ] if n . zero? || empty? list_tail . take ( - n ) end
Access the first n item(s) in the list.

 @param  n [Integer] the number of items to return.
 @return [Listable] if n = nil.
 @return [Array<Listable>] if n >= 0. The order is preserved.
Access the first n item ( s ) in the list .