Announcement

Collapse
No announcement yet.

Proper way to handle multiple type properties

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Proper way to handle multiple type properties

    Hello guys,

    I'm still working on the binding of TWGL.js and I encounter several time the following case:
    Some return value of functions or arguments can take several types.

    For example :
    color Array.<number> | ArrayBuffer
    src Array.<number> | ArrayBuffer | HTMLCanvasElement | HTMLImageElement | HTMLVideoElement |string | Array.<string> | module:twgl.TextureFunc

    Is there a good way to handle such cases ?
    Actually I just let it go as object, and specify in the documentation the possible value so the user will be able to cast it as needed, but I am not sure this is the best solution.

    Maxime.

    #2
    Bridge has Any type, it is designed for such cases
    Please see the following thread
    http://forums.bridge.net/forum/gener...tringorboolean

    Comment


      #3
      Thanks for your help, seems exactly what I needed. :)

      Comment

      Working...
      X