Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Methods

Each method of a C3 Type is defined by first giving the At a high-level, methods take in arguments or parameters and can return other objects. To define a method on a C3.ai Type, use the following syntax, method name followed by a colon ':' followed by a function signature, (e.g., function() or function(wattage: !decimal, bulbType: !string)), followed by a colon ':', followed by a return return C3.ai Type, along with a an implementation language and environment specification runtime execution. 

Function Signatures

Instead of a Type name following the name as with fields, methods have a function signature. the syntax looks like:

...

we see 'function' followed by a comma separated list of argument definitions. An argument definition consists of a parameter name followed by a colon ':', followed by a Type name. Optionally, you can also include an '!' before the parameter type to indicate that that argument is required.

Functions can be implemented in JavaScript, Python, or R. 


 input parameters, output parameters, implementation language, and execution location.

Return Types

After the function signature we have a return type. This must be a C3 type. The function must return an object of the appropriate type in the .

...

Finally, we end with a language and environment specificationruntime execution. 

Language Specifications

  • py: Use the 'py' keyword to indicate this is a Python function.
  • js: Use the 'js' keyword to indicate this is a JavaScript function.

Currently, these are the only two languages which the C3 AI Suite supports for native method definitions

Environment SpecificationRuntime Execution

Then, this is followed by an environment specification. for JavaScript the only two environments are:

...