Hacker News new | past | comments | ask | show | jobs | submit login

Actually, there is, just not as many upvotes as the others.

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



I 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.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: