--001636426cd39d65ee049eab6a0d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable What about something like this? defined?(Gem) && Gem.const_defined?(:Specification) // Magnus Holm On Thu, Mar 17, 2011 at 10:14, Nikolai Weibull <now / bitwi.se> wrote: > Hi! > > Why has defined? been changed for autoloaded constants in 1.9? > > In 1.8 the following prints "constant": > > autoload :A, 'a' > puts defined?(A) > > In 1.9 it prints nil. > > Why the change? I can see how it makes sense, sort of, but I have a test > for > > defined? ::Gem::Specification > > to test whether RubyGems has been loaded. > > How do I perform this test in 1.9? (I could of course change the test > to the less restrictive defined? ::Gem, but I want to know if there > a new way one should use for performing tests for loaded features like > this one.) > > Thanks! > > --001636426cd39d65ee049eab6a0d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div>What about something like this?</div><div><br></div>defined?(Gem) && Gem.const_defined?(:Specification)<div><br clear="all">// Magnus Holm<br> <br><br><div class="gmail_quote">On Thu, Mar 17, 2011 at 10:14, Nikolai Weibull <span dir="ltr"><now / bitwi.se></span> wrote:<br><blockquote class="gmail_quote" style="margin:08ex;border-left:1px #ccc solid;padding-left:1ex;"> Hi!<br> <br> Why has defined? been changed for autoloaded constants in 1.9?<br> <br> In 1.8 the following prints "constant":<br> <br> autoload :A, 'a'<br> puts defined?(A)<br> <br> In 1.9 it prints nil.<br> <br> Why the change? I can see how it makes sense, sort of, but I have a test for<br> <br> defined? ::Gem::Specification<br> <br> to test whether RubyGems has been loaded.<br> <br> How do I perform this test in 1.9? (I could of course change the test<br> to the less restrictive defined? ::Gem, but I want to know if there”Ēs<br> a new way one should use for performing tests for loaded features like<br> this one.)<br> <br> Thanks!<br> <br> </blockquote></div><br></div> --001636426cd39d65ee049eab6a0d--