3 ms·
Actually, there is, just not as many upvotes as the others. http://stackoverflow.com/a/2026849 http://stackoverflow.com/a/2026849 Basically, it is possible to
by cobrausn 15y ago
Actually, there is, just not as many upvotes as the others.
http://stackoverflow.com/a/2026849 http://stackoverflow.com/a/2026849
Basically, it is possible to inherit a random class in ruby.
class RandomSubclass < [Array, Hash, String, Fixnum, Float, TrueClass].sample
...
end
- raganwald 15y agoI wouldn’t call that a strange feature, just a surprising consequence of an un-strange feature, namely that inheritance involves expressions and that classes are first-class entities. Folks from certain other languages would be just as surprised to find out that you can alias classes by assigning them, return them from functions, and so on.