Managing metadata about attribute types

K

KUSUNOSE Toru

Hi,

In message said:
If I wanted a relevant subset of String, would that be better (i.e.
safer/faster) represented by a class/module representing that subset or
just one or a combination of respond_to?. I would argue most of the
time, that it is the former.

Sometimes, the latter is better.

For example, think Tempfile class. An instance of Tempfile
class responds to every methods an instace of the File class has,
so surely its type is File. But tmpfile.is_a? File is false.

That is, StrongTyping does not work well with the Delegator
pattern.
 
T

Thien Vuong

KUSUNOSE said:
Sometimes, the latter is better.

Definitely. I could see much good use of it.
Just only wanted to point out that it is not always one way or another.
For example, think Tempfile class. An instance of Tempfile
class responds to every methods an instace of the File class has,
so surely its type is File. But tmpfile.is_a? File is false.

Thanks for pointing it out. I wonder if I have some code needs to check
if it has a file behaviour or not (say the stream behavior plus about
10 differrent methods), how could I do it concisely? I could structure
the application such that it is not necessary, but it is not always
possible nor desirable to do so.
 

Ask a Question

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.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,139
Messages
2,570,807
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top