{"version":"1.0","blog_url":"https://rubyco.hatenadiary.org/","author_url":"https://blog.hatena.ne.jp/rubyco/","title":"if\u3068\u4e09\u9805\u6f14\u7b97\u5b50","type":"rich","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Frubyco.hatenadiary.org%2Fentry%2F20060128%2Fifvalue\" title=\"if\u3068\u4e09\u9805\u6f14\u7b97\u5b50 - rubyco\uff08\u308b\u3073\u3053\uff09\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","width":"100%","published":"2006-01-28 00:00:03","provider_url":"https://hatena.blog","categories":[],"blog_title":"rubyco\uff08\u308b\u3073\u3053\uff09\u306e\u65e5\u8a18","author_name":"rubyco","url":"https://rubyco.hatenadiary.org/entry/20060128/ifvalue","description":"Ruby\u306eif\u6587\u306f\u5024\u3092\u6301\u3061\u307e\u3059\u304b\u3089\u3001\u4e09\u9805\u6f14\u7b97\u5b50\u3068\u7b49\u4fa1\u306b\u306a\u308a\u307e\u3059\u3002 def abs1(n) if n > 0 return n else return -n end end def abs2(n) return n > 0 ? n : -n end def abs3(n) x = if n > 0 n else -n end return x end p abs1(-123) # => 123 p abs2(-123) # => 123 p abs3(-123) # => 123","image_url":null,"height":"190","provider_name":"Hatena Blog"}