title: In Ruby, how do I check if method "foo=()" is defined?
body: <p>In Ruby, I can define a method foo=(bar):</p>
  
  <pre><code>irb(main):001:0&gt; def foo=(bar)
  irb(main):002:1&gt;   p "foo=#{bar}"
  irb(main):003:1&gt; end
  =&gt; nil
  </code></pre>
  
  <p>Now I'd like to check if it has been defined,</p>
  
  <pre><code>irb(main):004:0&gt; defined?(foo=)
  SyntaxError: compile error
  (irb):4: syntax error, unexpected ')'
   from (irb):4
   from :0
  </code></pre>
  
  <p>What is the proper syntax to use here?  I assume there must be a way to escape "foo=" such that it is parsed and passed correctly to the defined? operator.</p>