LinkedIn principal author Doug Winnie explains how to return values from functions and methods. Inside of a function, you can take a value and send it back to where the function was called and end the function. When you return a variable, you are able to use the function anywhere that you can use a literal of variable in your code.
- Functions, sometimes called methods,…are tools for programmers to take common actions…and to group them to call using the function name.…With a function, you can send in values…for it to use and perform actions on it.…But you often need to get information out of it.…Because of variable's scope,…any variable that you create inside of it,…will be thrown away when the function is finished.…So you need to have a way to return a value…from the function when it is called.…There are three ways to work with a value.…
The first is to use a literal.…A literal is the value itself,…without any name or container.…It is simply the value.…So I could assign a variable…with a literal value, like five.…The second is to use a variable.…That variable has a value,…and I can assign that to another variable.…The third is with a function or method.…You essentially use it like a variable, or literal.…But to do this, you need to have it return a value.…
Like a variable, it will have a type.…In this case, the return type.…When you call the function and run the code inside of it,…
Join Doug Winnie as he explains the principles of programming and helps you connect to core concepts by exploring three ways that programmers perform their jobs. Doug starts by sharing the history of coding and then dives into functions, values, variables, and parameters used to define actions. He covers capturing input from users, creating conditional tests, using loops with arrays, and object-oriented programming basics. He also takes you beyond programming, into processes like debugging, refactoring, and building iteratively.
- Working with values and variables
- Breaking down tasks
- Customizing functions and parameters
- Building conditional tests
- Creating and changing arrays
- Working with objects and classes
- Debugging and refactoring code
- Going beyond the code as a programmer
Skill Level Beginner
1. Control Computers with Code
2. Define Actions Using Code
3. Repeat Actions and Test for Conditions
4. Objects and OOP
5. Beyond Programming
Debug problems2m 50s
Next steps1m 19s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.