Skip to content

Instantly share code, notes, and snippets.

@mktakuya
Created April 29, 2014 12:22
Show Gist options
  • Save mktakuya/11398646 to your computer and use it in GitHub Desktop.
Save mktakuya/11398646 to your computer and use it in GitHub Desktop.
Rubyはreturnを省略できるらしい。こわい。
#!/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