<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>osyo-manga</author_name>
  <author_url>https://blog.hatena.ne.jp/osyo-manga/</author_url>
  <blog_title>Secret Garden(Instrumental)</blog_title>
  <blog_url>https://secret-garden.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>Ruby で使用できる単項演算子を調べてみた。 Ruby では +, -, ~, ! が単項演算子と使用でき、さらに再定義することもできます。 [コード] class X def +@ p &quot;+&quot; end def -@ p &quot;-&quot; end def ~ p &quot;~&quot; end def ! p &quot;!&quot; end end def ` str p str end x = X.new +x -x ~x !x [出力] &quot;+&quot; &quot;-&quot; &quot;~&quot; &quot;!&quot; Ruby では + や - は二項演算子も存在するので、再定義する場合のメソッド名は +@ や -@ とする必要があります。</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fsecret-garden.hatenablog.com%2Fentry%2F2015%2F10%2F31%2F195512&quot; title=&quot;Ruby で使用できる単項演算子 - Secret Garden(Instrumental)&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>2015-10-07 19:55:12</published>
  <title>Ruby で使用できる単項演算子</title>
  <type>rich</type>
  <url>https://secret-garden.hatenablog.com/entry/2015/10/31/195512</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
