Skip to content

cthomas0100001/Robot-Function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robot Function

A simple funciton to illustrate a function and how it works at its base.

func getMilk(howManyMilkCartons : Int, howMuchMoneyRobotWasGiven : Int) -> Int {

   print("go to the shop")
   print("buy \(howManyMilkCartons) cartons of milk")

let priceToPay = howManyMilkCartons * 2

    print("pay $\(priceToPay)")
    print("go home")

let change = howMuchMoneyRobotWasGiven - priceToPay

return change

}

var amountOfChange = getMilk(howManyMilkCartons: 1, howMuchMoneyRobotWasGiven: 10 ) // Type in how many cartons of milk and how much money you gave.

print ("Hello Master, here's your $(amountOfChange) change")

About

A simple code to show how a function works.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages