mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
- Add length check with explicit panic message - Update documentation to note panic behavior - Tests already exist and pass Resolves Issue 13 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
10 lines
231 B
Go
10 lines
231 B
Go
package underscore
|
|
|
|
// Last returns the last element of the slice.
|
|
// Panics if the slice is empty.
|
|
func Last[T any](values []T) T {
|
|
if len(values) == 0 {
|
|
panic("underscore.Last: empty slice")
|
|
}
|
|
return values[len(values)-1]
|
|
}
|