Skip to content

Commit

Permalink
p.146 introduce temporary variable "shipping" .
Browse files Browse the repository at this point in the history
  • Loading branch information
kono committed May 22, 2010
1 parent 15bb3b2 commit f70b45c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions chapter6/Introduce_Explaining_Variable.rb
Expand Up @@ -9,9 +9,8 @@ def price
# 価格は、基本価格 - 数量割引 + 配送料
base_price = @quantity * @item_price
quantity_discount = [0, @quantity - 500].max * @item_price * 0.05
return base_price -
quantity_discount +
[base_price * 0.1,100.0].min
shipping = [base_price * 0.1, 100.0].min
return base_price - quantity_discount + shipping
end
end

0 comments on commit f70b45c

Please sign in to comment.