PasteRack.org
Paste # 43507
2015-04-23 05:06:20

Fork as a new paste.

Paste viewed 49 times.


Embed:

subclass method problem

  1. #lang racket
  2.  
  3. (define top-class%
  4.   (class object%
  5.     (super-new)
  6.  
  7.     (define/public (a-method)
  8.       (displayln "Hello from top class"))))
  9.  
  10. (define sub-class%
  11.   (class top-class%
  12.     (super-new)
  13.  
  14.     (define/private (another-method)
  15.       (displayln "Hello from another method"))
  16.  
  17.     (define/override (a-method)
  18.       (displayln "Hello from sub class")
  19.       (send this another-method))))
  20.  
  21. (send (new sub-class%) a-method)

=>

Hello from sub class

send: no such method

  method name: another-method

  class name: sub-class%