Back
Blog: Conspiracy Theory
J1351: Source Control

CS-II Journal J1351: Source Control

Name: Tiffany Jiang

Date: 8/22/2023

I received assistance from: NO ONE

I assisted: NO ONE

 

Section 1

1.1 What syntax errors do you notice in the above code?

It is impossible to edit variables who have been set using the "let" term.

1.2 What logic errors do you see in the above code?

When you set x as y in line 4, they are then the same number, and the number that x originally represented would no longer exist. Thus, when you set y as x in line 5, nothing changes.


Section 2

2.1 What will be the value of x after the code executes?

It will gain the value of y.

2.1 What will be the value of y after the code executes?

It will not change


Section 3

What must be done to properly swap the variables>

A third variable (for example, z) must be created to temporarily hold the integar of the first variable that swaps (x), and then you must swap the other variable (y) with to the integar that z z represents.


Section 4

Will the above code compile correctly> If not, why not?

It will not compile correctly because the function is changing a variable that has been set outside of the function, and it will protect against that.


Section 5

Carefully compare the above code segment to the previous segment. What changes are required to modify the value of a (value-type) argument in a function?

"inout" is added to the function declaration line right before the declaration that the variable "n" is an Integar. When calling the function, an ampersand sign is also added right before "x".

 

What challenges did I encounter?

Looking at the inout part of the function was kind of confusing.

How could this experience be improved?

I think it was pretty clear.

What did I learn? What is the "big idea?"

I learned about the inout part of the function and the ampersand we needed to add if we wanted to edit variables that we use in the function.

Free Reflection: How has what I've learned affected my thinking?

There are more methods that I need to learn from swift that are useful.

CS-II