Writing Classes - Inherited method not understood

when would you use super instead of this ?

perhaps see Eliot Miranda’s explanation? it’s quite concise…

https://scsynth.org/t/using-superperform/5286/3

How do you differentiate them to call a class method rather than an instance method?

you don’t!

this is always the receiver of the message

in Signal.hanningWindow it’s Signal and

Signal.isKindOf(Class) == true

in Signal.new.size the receiver of size is Signal.new and

Signal.new.isKindOf(Signal)

there are some abstract classes on the edges but the “metaphysics” is still more or less as in this diagram:

3.14.class == Float
42.class == Integer
Float.class.class == Class
Integer.class.class == Class
Class.class.class = Class

Float.superclass.superclass == Number
Integer.superclass.superclass == Number
Number.superclass.superclass == Object
Object.superclass = nil

Object.class.class == Class
Class.superclass == Object
1 Like