Skip to content

Conversation

@rjNemo
Copy link
Owner

@rjNemo rjNemo commented Nov 14, 2025

Summary

  • Add Init: returns all elements except the last one, and the last element separately
  • Useful for list destructuring from the right

Implementation

  • init.go: Init implementation with proper memory allocation
  • Comprehensive tests including edge cases (empty, single, two elements)
  • Non-mutating: returned slice is a copy
  • Benchmark included

Testing

go test -v -run TestInit
go test -bench=BenchmarkInit -benchmem

All tests pass.

Examples

Init([]int{1,2,3,4,5})    // ([1,2,3,4], 5)
Init([]int{42})           // ([], 42)
Init([]int{})             // ([], 0)
Init([]string{"a","b"})   // (["a"], "b")

Related

Resolves Issue 17 from ACTION_PLAN.md

🤖 Generated with Claude Code

- Add Init: returns all elements except last, and the last element
- Useful for destructuring lists from the right
- Comprehensive tests including edge cases
- Benchmark included

Example: Init([1,2,3,4,5]) → ([1,2,3,4], 5)

Resolves Issue 17

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.67%. Comparing base (d622c8c) to head (3df26bb).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #45      +/-   ##
==========================================
+ Coverage   98.63%   98.67%   +0.03%     
==========================================
  Files          39       40       +1     
  Lines         367      376       +9     
==========================================
+ Hits          362      371       +9     
  Misses          4        4              
  Partials        1        1              
Flag Coverage Δ
unittests 98.67% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rjNemo rjNemo merged commit 260c48e into main Nov 16, 2025
4 checks passed
@rjNemo rjNemo deleted the feat/issue-17-init branch November 16, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants