I admit that in duck-typing languages, abstract classes aren't used so often, so this question is more out of curiosity than of actual need:
In Ruby (at least 2.0), Fixnum
and Bignum
have a common superclass called Integer
. It looks to me, that this is an abstract class; at least, it can't be instantiated, i.e. when you do in irb:
irb(main):047:0> Integer.new(8)
NoMethodError: undefined method `new' for Integer:Class
from (irb):47
from /usr/bin/irb:12:in `<main>'
Now, if I would decide to roll out my own class which behaves like Integer
, i.e. being "as abstract as Integer
is", how would I do this? I thought that every class contains a (hidden) new
method (which calls my initialize
method if present).