H
Hal Fulton
OK, I've been thinking (always dangerous after 11 pm).
Class-level entities can be accessed via a double-colon.
No big mystery:
File:pen(...)
File::SEPARATOR
Happily, a class method can also be accessed via a dot:
File.open(...)
But a constant can't:
File.SEPARATOR # syntax error
First, why is it this way?
Personally, I don't like the :: anyway, as it reminds me
of C++.
By the way, for those who are wondering, this *is* possible:
class File
def self.SEPARATOR
File::SEPARATOR
end
end
File.SEPARATOR # "/"
Even though it looks almost like recursion. Hmm, that raises
the question of why/how this works.
And another issue is: One *could* write a little module that,
when included in a class, exposed all the class's constants in
this way. Within five minutes I had it "almost" working. I'll
bet someone in another timezone or with more caffeine could
have it working in three. Anyone?
Hal
Class-level entities can be accessed via a double-colon.
No big mystery:
File:pen(...)
File::SEPARATOR
Happily, a class method can also be accessed via a dot:
File.open(...)
But a constant can't:
File.SEPARATOR # syntax error
First, why is it this way?
Personally, I don't like the :: anyway, as it reminds me
of C++.
By the way, for those who are wondering, this *is* possible:
class File
def self.SEPARATOR
File::SEPARATOR
end
end
File.SEPARATOR # "/"
Even though it looks almost like recursion. Hmm, that raises
the question of why/how this works.
And another issue is: One *could* write a little module that,
when included in a class, exposed all the class's constants in
this way. Within five minutes I had it "almost" working. I'll
bet someone in another timezone or with more caffeine could
have it working in three. Anyone?
Hal