<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>straitwalk</author_name>
  <author_url>https://blog.hatena.ne.jp/straitwalk/</author_url>
  <blog_title>成らぬは人の為さぬなりけり</blog_title>
  <blog_url>https://straitwalk.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>Rubyの条件式の結果は、 nilとfalse以外はすべてtrue となりますよね？なので、 def hoge &quot;a&quot; end if hoge p &quot;TRUE&quot; else p &quot;FALSE&quot; end これの結果は &quot;TRUE&quot; となります。しかし、 hogeメソッドの戻り値は、あくまで「a」であり、 「true」ではありません。「hoge?」みたいなメソッドにする場合、 結果をbool値にしたい場合があります。 そういう場合には、こう書きます。 def hoge? !!&quot;a&quot; end これで、「hoge?」の戻り値はbool値になります。 ruby-1.9.2-p290 :001 &gt; !!&quot;a…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fstraitwalk.hatenablog.com%2Fentry%2F20111007%2F1318005046&quot; title=&quot;bool値に変換する「!!」 - 成らぬは人の為さぬなりけり&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2011-10-07 01:30:46</published>
  <title>bool値に変換する「!!」</title>
  <type>rich</type>
  <url>https://straitwalk.hatenablog.com/entry/20111007/1318005046</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
