Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/money/money/allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def self.generate(amount, parts, whole_amounts = true)

result = []
remaining_amount = amount

parts_sum = parts.sum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the change from inject to sum 😍


until parts.empty? do
parts_sum = parts.inject(0, :+)
part = parts.pop

current_split = 0
Expand All @@ -48,6 +48,7 @@ def self.generate(amount, parts, whole_amounts = true)

result.unshift current_split
remaining_amount -= current_split
parts_sum -= part
end

result
Expand Down