This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_extPart_001_01C07944.FCDF17F0
Content-Type: text/plain; 
 charseto-8859-1
Content-Transfer-Encoding: 7bit

Hi,

I was mainly thinking about abstract in the java sense:
non-instatiable classes with methods that are to be 
implemented in subclasses:

something like:

class Employee
  def-abstract-method work;
  ... other ...
end

class Worker << Employee
  def work
    # do the worker job
  end
  ... other ...
end

class << Secretary
  # work not impemented
  ... other
end

1. Worker.new(...).work    #-> OK
2. Secretary.new(...).work #-> Error: abstract mathod "work" not implemented
3. Employee.new(...)       #-> Error: cannot instatiate abstract class

I know that "work" could be implemented in Employee with an exception
thrown.
This would solve case 2, but still an Employee could be instantiated (3.),
which
conceptually is not a good thing.

Is the solution to declare Emplyee as a module?

maurice

# 
# >is there any way to declare abstract classes/methods in ruby?
# 
# It depends on what you mean by abstract classes. 
# You can prevent people from invoking a new 
# operator by making it a protected method.
# 
# Can you give an example of what you would like to 
# accomplish?
# 
# Kevin
# 

------_extPart_001_01C07944.FCDF17F0
Content-Type: text/html; 
 charseto-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV
ontent-Type" CONTENText/html; charseto-8859-1"> <META NAMEenerator" CONTENTS Exchange Server version 5.5.2651.75"> <TITLE>RE: [ruby-talk:8754] Re: abstract classes</TITLE> </HEAD> <BODY> <P><FONT SIZE Hi,</FONT> </P> <P><FONT SIZE I was mainly thinking about abstract in the java sense:</FONT> <BR><FONT SIZE non-instatiable classes with methods that are to be </FONT> <BR><FONT SIZE implemented in subclasses:</FONT> </P> <P><FONT SIZE something like:</FONT> </P> <P><FONT SIZE class Employee</FONT> <BR><FONT SIZE &nbsp; def-abstract-method work;</FONT> <BR><FONT SIZE &nbsp; ... other ...</FONT> <BR><FONT SIZE end</FONT> </P> <P><FONT SIZE class Worker &lt;&lt; Employee</FONT> <BR><FONT SIZE &nbsp; def work</FONT> <BR><FONT SIZE &nbsp;&nbsp;&nbsp; # do the worker job</FONT> <BR><FONT SIZE &nbsp; end</FONT> <BR><FONT SIZE &nbsp; ... other ...</FONT> <BR><FONT SIZE end</FONT> </P> <P><FONT SIZE class &lt;&lt; Secretary</FONT> <BR><FONT SIZE &nbsp; # work not impemented</FONT> <BR><FONT SIZE &nbsp; ... other</FONT> <BR><FONT SIZE end</FONT> </P> <P><FONT SIZE 1. Worker.new(...).work&nbsp;&nbsp;&nbsp; #-&gt; OK</FONT> <BR><FONT SIZE 2. Secretary.new(...).work #-&gt; Error: abstract mathod &quot;work&quot; not implemented</FONT> <BR><FONT SIZE 3. Employee.new(...)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #-&gt; Error: cannot instatiate abstract class</FONT> </P> <P><FONT SIZE I know that &quot;work&quot; could be implemented in Employee with an exception thrown.</FONT> <BR><FONT SIZE This would solve case 2, but still an Employee could be instantiated (3.), which</FONT> <BR><FONT SIZE conceptually is not a good thing.</FONT> </P> <P><FONT SIZE Is the solution to declare Emplyee as a module?</FONT> </P> <P><FONT SIZE maurice</FONT> </P> <P><FONT SIZE # </FONT> <BR><FONT SIZE # &gt;is there any way to declare abstract classes/methods in ruby?</FONT> <BR><FONT SIZE # </FONT> <BR><FONT SIZE # It depends on what you mean by abstract classes. </FONT> <BR><FONT SIZE # You can prevent people from invoking a new </FONT> <BR><FONT SIZE # operator by making it a protected method.</FONT> <BR><FONT SIZE # </FONT> <BR><FONT SIZE # Can you give an example of what you would like to </FONT> <BR><FONT SIZE # accomplish?</FONT> <BR><FONT SIZE # </FONT> <BR><FONT SIZE # Kevin</FONT> <BR><FONT SIZE # </FONT> </P> </BODY> </HTML> ------_extPart_001_01C07944.FCDF17F0--