// Last returns the last error in the slice. It returns nil if the array is empty.
// Shortcut for errors[len(errors)-1].
979026
func (a errorMsgs) Last() *Error {
	if length := len(a); length > 0 {
		return a[length-1]
	}
	return nil
}
330341
func (p *Prefix) Last() net.IP {
	if p.IP.To4() != nil {
		i := p.lastIPv4Int()
		return i.ip()
	}
	if p.IP.To16() != nil && p.IP.To4() == nil {
		i := p.lastIPv6Int()
		return i.ip()
	}
	return nil
}
1295071
func (nc *Conn) LastError() error {
	if nc == nil {
		return ErrInvalidConnection
	}
	nc.mu.RLock()
	err := nc.err
	nc.mu.RUnlock()
	return err
}
366240
func Aggregate(errors []error) error {
	if len(errors) == 0 {
		return nil
	}
	return New(aggregateCodes(errors), aggregateErrors(errors))
}
1349645
func (ns *Namespace) Last(limit interface{}, seq interface{}) (interface{}, error) {
	if limit == nil || seq == nil {
		return nil, errors.New("both limit and seq must be provided")
	}

	limitv, err := cast.ToIntE(limit)
	if err != nil {
		return nil, err
	}

	if limitv < 1 {
		return nil, errors.New("can't return negative/empty count of items from sequence")
	}

	seqv := reflect.ValueOf(seq)
	seqv, isNil := indirect(seqv)
	if isNil {
		return nil, errors.New("can't iterate over a nil value")
	}

	switch seqv.Kind() {
	case reflect.Array, reflect.Slice, reflect.String:
		// okay
	default:
		return nil, errors.New("can't iterate over " + reflect.ValueOf(seq).Type().String())
	}

	if limitv > seqv.Len() {
		limitv = seqv.Len()
	}

	return seqv.Slice(seqv.Len()-limitv, seqv.Len()).Interface(), nil
}
800707
func LastIndexOfInt(a []int, x int) int {
	return lastIndexOf(len(a), func(i int) bool { return a[i] == x })
}
1094548
func (ps PointSet) Last() *Point {
	if len(ps) == 0 {
		return nil
	}

	return &ps[len(ps)-1]
}
313267
func (r *sampleRing) last() (int64, float64, bool) {
	if r.l == 0 {
		return 0, 0, false
	}
	s := r.buf[r.i]
	return s.t, s.v, true
}
298008
func (q Query) LastWith(predicate func(interface{}) bool) (r interface{}) {
	next := q.Iterate()

	for item, ok := next(); ok; item, ok = next() {
		if predicate(item) {
			r = item
		}
	}

	return
}
630112
func (rs Recoverings) Last() *Recovering {
	if len(rs) > 0 {
		return rs[len(rs)-1]
	}
	return nil
}
67324
func lastFunc(q query, t iterator) interface{} {
	var (
		count = 0
		node  = t.Current()
	)
	node.MoveToFirst()
	test := predicate(q)
	for {
		if test(node) {
			count++
		}
		if !node.MoveToNext() {
			break
		}
	}
	return float64(count)
}
142195
func (e *Errors) Append(err *Errors) error {
	if err == nil {
		return nil
	}

	e.m.Lock()

	// append Errors at the end of the current list
	e.err = append(e.err, err.err...)

	// set highest priority
	if err.p > e.p {
		e.p = err.p
	}

	e.m.Unlock()
	return nil
}
265685
func (c *Cursor) Last() *Position {
	return &Position{IP: c.ps[len(c.ps)-1].Last(), Prefix: c.ps[len(c.ps)-1]}
}
187293
func (c *Cursor) Last() (key []byte, value []byte) {
	_assert(c.bucket.tx.db != nil, "tx closed")
	c.stack = c.stack[:0]
	p, n := c.bucket.pageNode(c.bucket.root)
	ref := elemRef{page: p, node: n}
	ref.index = ref.count() - 1
	c.stack = append(c.stack, ref)
	c.last()
	k, v, flags := c.keyValue()
	if (flags & uint32(bucketLeafFlag)) != 0 {
		return k, nil
	}
	return k, v
}
514499
func (p *MediaPlaylist) last() uint {
	if p.tail == 0 {
		return p.capacity - 1
	}
	return p.tail - 1
}
532394
func (c *Client) LastSave() (int64, error) {
	var ret int64
	err := c.command(
		&ret,
		[]byte("LASTSAVE"),
	)
	return ret, err
}
797092
func LastNLines(s string, n int) string {
	trimmed := strings.Trim(s, "\n")
	splitted := strings.Split(trimmed, "\n")

	if len(splitted) >= n {
		splitted = splitted[len(splitted)-n:]
	}

	return strings.Join(splitted, "\n")
}