Skip to content

Commit

Permalink
p.49 make shorter the function "total_charge"
Browse files Browse the repository at this point in the history
  • Loading branch information
kono committed Apr 6, 2010
1 parent 5134d57 commit 398773d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions chapter1/Customer.rb
Expand Up @@ -32,11 +32,7 @@ def statement
private

def total_charge
result = 0
@rentals.each do |element|
result += element.charge
end
result
@rentals.inject(0){|sum, rental| sum + rental.charge}
end

end

0 comments on commit 398773d

Please sign in to comment.