A generic function constrained by Shape: methods on T

The complete source of generics_constrained.ek9, compiled by the EK9 compiler. Shown on generics.html.

#!ek9
defines module site.generics.constrained

  defines function
    eventHandler of type T constrain by Shape
      -> shape as T
      require shape?
      require shape.description()?
      //any other 'method' on Shape can be used

  defines class

    Shape as abstract
      description() as pure abstract
        <- rtn as String?

Download generics_constrained.ek9