From the course: Learning Functional Programming with Swift
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Keeping functions and data separate - Swift Tutorial
From the course: Learning Functional Programming with Swift
Keeping functions and data separate
- [Instructor] The second major concept of functional programming is the separation of data and functions. For our purposes, data might be any values that a program contains: people's names, addresses, and social security numbers in a payroll program, the models, years, and colors of cars on a used car website, the positions, health levels, and weapons of characters in a video game, anything. Functions, on the other hand, might be any operation that we can apply to our data to convert it into useful information. For example, if we want to find the average salary of programmers at our company, find all the cars on our website that were made after a certain year, or find if two characters are colliding in a video game. If you're coming from an object-oriented background, it may seem strange to you that functional programming places an emphasis on keeping data and functions separate since one of the central concepts of object-oriented programming is that we put data and the functions…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.