Z
Zhao Yi
I require two ruby files which include two classes with the same name.
how can I specify which class I use?
how can I specify which class I use?
I require two ruby files which include two classes with the same name.
how can I specify which class I use?
Ryan said:class X; end # x.rb
class X; end # y.rb
same class, only one to specify. Files mean nothing in ruby, they're
just vehicles for the parser.
Why not answer this empirically? Try it out!Zhao said:For this code:
require 'x.rb'
require 'y.rb'
X.new #which class it uses, can I specify the class like x.X or y.X?
Tom said:Why not answer this empirically? Try it out!
Zhao said:I have tried but failed. This is my code:
logger=log4r.Logger.new
and I got the error: undefined local variable or method log4r
Zhao said:For this code:
require 'x.rb'
require 'y.rb'
X.new #which class it uses, can I specify the class like x.X or y.X?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.