diff --git a/README.md b/README.md index 5fa2e65..f697337 100644 --- a/README.md +++ b/README.md @@ -450,6 +450,52 @@ param parCustomArray arrayWithObjectsType = [ + + + User Defined Functions + Define custom complex expressions. + + +### User-defined function syntax + +```func ( ) => ``` + +### Basic user-defined function + +```bicep +func funcSayHelloTo() string => 'Hello and welcome, John Doe' +``` + +### User-defined function with parameters + +```bicep +func funcSayHelloTo(name string) string => 'Hello and welcome, ${name}' +``` + +With multiple parameters: + +```bicep +func funcPersonNameAndAge(name string, age int) string => 'My name is ${name} and my age is ${age}' +``` + +### User-defined function return types + +```bicep +func funcReturnTypeArray() array => [1, 2, 3, 4, 5] +func funcReturnTypeObject() object => {name: 'John Doe', age: 31} +func funcReturnTypeInt() int => 1337 +func funcReturnTypeBool(key string) bool => contains({}, key) +func funcReturnTypeUserDefinedType() customTypeUsedAsReturnType => { + hello: 'world' +} + +type customTypeUsedAsReturnType = { + hello: string +} +``` + + + Compile-time imports
Define custom complex expressions.