class Nokogiri::XML::NodeSet

def first(n = nil)

Experimental RBS support (using type sampling data from the type_fusion project).

def first: (?nil n) -> nil

This signature was generated using 9 samples from 1 application.

Get the first element of the NodeSet.
##
def first(n = nil)
  return self[0] unless n
  list = []
  [n, length].min.times { |i| list << self[i] }
  list
end