From the course: Learning Julia

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Functions

Functions - Julia Tutorial

From the course: Learning Julia

Start my 1-month free trial

Functions

- [Instructor] Functions are yet another foundational building block of modern programming that encapsulate distinct pieces of logic. So here in my editor I'm going to open the functions_start file and we're going to exercise some of Julia's function features. Now we've already seen a few simple examples of functions in the course but here we're going to take a look a little bit deeper at how you can use the functions in Julia. So to start off, functions are defined using the function keyword and they're given a name. So in this case I'll use myfunc and I'll give my function two arguments; a and b. Now by convention function names are usually all lower case and might contain underscores if the name is hard to read. So inside the function we're going to define the logic and I'll just have a print line statement that says This is a function and then I'm going to return adding the two arguments together. And then at the end of the function we have the end keyword which is what closes the…

Contents