title: How can I pass a method as an argument in Ruby?
body: <p>I am passing a method as an argument to a called function:</p>
  
  <pre><code>def my_function(args1)
     puts args1
  end
  
  def my_calling_method
     self.my_function(def do_this 
               return 2*3
             end)
  end
  </code></pre>
  
  <p>When I call <code>my_calling_method</code> which makes a call to <code>my_function</code>, I am getting <code>args1</code> as nil instead of <code>def do_this return 2*3 end</code>.</p>
  
  <p>Am I doing anything wrong? Can we pass method as an argument in Ruby?</p>
  
  <p>Alright, I tried implemented a Proc for my requirement now but I am having a hard time to pass it to the calling method.</p>
  
  <pre><code>my_Proc = Proc.new do
      return 2*3
  end
  
  def my_calling_method
      self.my_function
  end
  
  def my_function my_Proc
     my_Proc.call
  end
  </code></pre>
  
  <p>The reference material I used passes a Proc as an argument to the method like I do, but I am getting error, zero arguments passed to my_function as I am not passing any argument through my_calling_method.</p>