TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: Day-5 Inout Parameters(i.e)

Forums > 100 Days of SwiftUI

For example, if you want to double a number in place – i.e., change the value directly rather than returning a new one – you might write a function like this:

In this sentence Paul said i.e but ı dont know what does it mean. Can anyone explain?

3      

He means that you could write a function like this to double a number and return the value...

var myNumber = 5

func doubleAndReturn(number: Int) -> Int {
    return number * 2
}

myNumber = doubleAndReturn(myNumber)

print(myNumber)

(Notice that this function returns an Int, and we set myNumber equal to the thing that is returned when we call the function.)

Or your could write a function like this to double the number in place...

var myNumber = 5

func doubleInPlace(number: inout Int) {
    number *= 2
}

doubleInPlace(myNumber)

print(myNumber)

(Notice here that this function does not return anything, and we do not need to set our variable equal to the return value of the function. We simply call the function, and the variable's value is changed inside of the function when the function is called.)

4      

Maybe I misunderstood the question...

If you are just asking what "i.e." means, it is an abbreviation for the Latin phrase "Id est" which means "That is"

It's sometimes used as an alternative to saying "In other words" or "For Example"

4      

Howdy,

To build on FlyOstrich's idea the original sentence may be read as...

For example, if you want to double a number in place – that is to say, change the value directly rather than returning a new one – you might write a function like this:

I'm assuming Paul then writes a function in the video.

4      

Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.