Functions

A set of blocks that allow you to create and call functions. Functions are handy for structuring and reusing repetitive logic

../../../_images/image_13.png

You can define functions with or without a return value

../../../_images/image_23.png

You can define functions that accept parameters as input arguments

../../../_images/gif_1.gif

You can add a description to any function

../../../_images/image_32.png

Once you have defined a function, blocks will appear in the “Functions” section to call it

../../../_images/image_42.png

A block for calling a function without parameters that does not return a value

../../../_images/image_5.png

A block for calling a function with parameters and a return value

../../../_images/image_6.png

Example

Let’s create a function that calculates the length of the hypotenuse. It will take the length of the legs as parameters

../../../_images/image_7.png

Simple functions like this can be written shorter - move the hypotenuse calculation to “return”, and in the function settings uncheck “Allow operators”

../../../_images/image_8.png

Function call

../../../_images/image_9.png