Slide 10
Slide 10 text
● 共通の処理を関数(サブルーチン)に切り出す
関数に切り出す
def hoge
...
taxed_item_price = item_price * 1.1
...
end
def fuga
...
taxed_item_price = item_price * 1.1
...
end
def hoge
...
taxed_item_price = taxed_item_price(item_price)
...
end
def fuga
...
taxed_item_price = taxed_item_price(item_price)
...
end
def taxed_item_price(item_price)
item_price * 1.1
end
消費税計算を行う処理を関数化して再利用→