func (s *SinglyLinkedList[T]) RemoveAt(index int) (res T, err error) {
	if index < 0 || index >= s.count {
		return res, errIndexOutOfBounds
	}

	if s.count == 1 {
		res = s.head.Value
		s.head = nil
		s.tail = nil
		s.count--
		return res, nil
	}

	if index == 0 {
		current := s.head
		s.head = current.Next
		current.Next = nil
		res = current.Value
		s.count--
		current = nil
		return res, nil
	}

	current, err := s.getNode(index - 1)
	if err != nil {
		return res, err
	}

	res = current.Next.Value
	current.Next = current.Next.Next
	if index == s.count-1 {
		s.tail = current
	}
	s.count--
	current = nil
	return res, nil
}
// RemoveAt remove value from the list at specific index
RemoveAt remove value from the list at specific index
// RemoveAt remove value from the list at specific index
func (s *SinglyLinkedList[T]) RemoveAt(index int) (res T, err error) {
	if index < 0 || index >= s.count {
		return res, errIndexOutOfBounds
	}
	if s.count == 1 {
		res = s.head.Value
		s.head = nil
		s.tail = nil
		s.count--
		return res, nil
	}
	if index == 0 {
		current := s.head
		s.head = current.Next
		current.Next = nil
		res = current.Value
		s.count--
		current = nil
		return res, nil
	}
	current, err := s.getNode(index - 1)
	if err != nil {
		return res, err
	}
	res = current.Next.Value
	current.Next = current.Next.Next
	if index == s.count-1 {
		s.tail = current
	}
	s.count--
	current = nil
	return res, nil
}
func ( s * SinglyLinkedList [ T ] ) RemoveAt ( index int ) ( res T , err error ) { if index < 0 || index >= s . count { return res , errIndexOutOfBounds } if s . count == 1 { res = s . head . Value s . head = nil s . tail = nil s . count -- return res , nil } if index == 0 { current := s . head s . head = current . Next current . Next = nil res = current . Value s . count -- current = nil return res , nil } current , err := s . getNode ( index - 1 ) if err != nil { return res , err } res = current . Next . Value current . Next = current . Next . Next if index == s . count - 1 { s . tail = current } s . count -- current = nil return res , nil }
RemoveAt remove value from the list at specific index
RemoveAt remove value from the list at specific index