Created
April 29, 2014 12:22
-
-
Save mktakuya/11398646 to your computer and use it in GitHub Desktop.
Rubyはreturnを省略できるらしい。こわい。
This file contains 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
#!/usr/bin/env ruby | |
# coding:utf-8 | |
def abs(data) | |
if data >= 0 then | |
data | |
else | |
data *= -1 | |
end | |
end | |
puts abs(5) # これで 5 が出力される。 | |
puts abs(-4) # これで 4 が出力される。 | |
# Rubyコワイ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment