Different behaviour when running script vs IRB console? : <p>I have a simple code snippet that defines a method (on Ruby's Main Object), and then checks to see if it is defined.</p>

<pre><code>puts "#{self} #{self.class}"
def foo;end
puts self.methods.include?(:foo)
</code></pre>

<p>When I run this in a Ruby console. I get:</p>

<pre><code>main Object
true
</code></pre>

<p>If I paste this code into a .rb file and run the file like so <code>ruby test_script.rb</code>, I get the following output</p>

<pre><code>main Object
false
</code></pre>

<p>I can't work out why I am seeing this behaviour. The method <em>is</em> being defined in the script, as I can call the method.</p>

<p>I'm running both on Ruby 2.3.4</p>
