Last active
February 15, 2020 07:47
-
-
Save SyunWatanabe/d94c4f001b4be6825531872a34fd6e7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 長さの単位変換プログラム | |
| def convert_length(num, unit, conversion) | |
| hash = {'m' => 1.00, 'ft' => 3.28, 'in' => 39.37} | |
| (num * hash[conversion] / hash[unit]).round(2) | |
| end | |
| puts convert_length(1, 'm', 'in') | |
| puts convert_length(15, 'in', 'm') | |
| puts convert_length(35_000, 'ft', 'm') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment