Why is not work?


#1

Hi all,

module A
end
A.autoload(:B, “b”)
A::B.doit # autoloads “b”

result :
uninitialized constant A::B (NameError)


#2

On 7/19/07, Chung C. removed_email_address@domain.invalid wrote:

Hi all,

module A
end
A.autoload(:B, “b”)
A::B.doit # autoloads “b”

result :
uninitialized constant A::B (NameError)

Do you have a file named “b”?


#3

Todd B. wrote:

On 7/19/07, Chung C. removed_email_address@domain.invalid wrote:

Hi all,

module A
end
A.autoload(:B, “b”)
A::B.doit # autoloads “b”

result :
uninitialized constant A::B (NameError)

Do you have a file named “b”?

Hi,

Yes, I have.

A.autoload?(:B) # “b”


#4

Chung C. wrote:

Todd B. wrote:

On 7/19/07, Chung C. removed_email_address@domain.invalid wrote:

Hi all,

module A
end
A.autoload(:B, “b”)
A::B.doit # autoloads “b”

result :
uninitialized constant A::B (NameError)

Do you have a file named “b”?

Hi,

Yes, I have.

A.autoload?(:B) # “b”

irb(main):001:0> module A
irb(main):002:1> end
=> nil
irb(main):003:0> A.autoload(:B,“b”)
=> nil
irb(main):004:0> A.autoload?(:B)
=> “b”
irb(main):005:0> A::B.hello
NameError: uninitialized constant A::B
from (irb):5
irb(main):006:0> require “b”
=> false
irb(main):007:0> B.hello
“hello”
=> nil


#5

Hi,

At Fri, 20 Jul 2007 10:12:47 +0900,
Chung C. wrote in [ruby-talk:260876]:

irb(main):006:0> require “b”
=> false
irb(main):007:0> B.hello
“hello”
=> nil

Seems b.rb defines ::B but doesn’t A::B.