Skip to content

Commit f01e877

Browse files
committed
update ctrl+alt+shift+L
1 parent 5e03831 commit f01e877

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

core-kotlin-modules/core-kotlin-10/src/test/kotlin/com/baeldung/variableshadowing/VariableShadowingUnitTest.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import org.junit.jupiter.api.Test
88
class VariableShadowingUnitTest {
99

1010
@Test
11-
fun `top-level variable shadowing`(){
11+
fun `top-level variable shadowing`() {
1212
val number = 10 // Top-level variable
1313

14-
fun upNumber() : Int { // top-level function
14+
fun upNumber(): Int { // top-level function
1515
val number = 20 // shadowing top-level variable
1616
return number
1717
}
@@ -21,10 +21,10 @@ class VariableShadowingUnitTest {
2121
}
2222

2323
@Test
24-
fun `solution to avoid top-level variable shadowing`(){
24+
fun `solution to avoid top-level variable shadowing`() {
2525
val topLevelNumber = 10 // Top-level variable
2626

27-
fun upNumber() : Int {
27+
fun upNumber(): Int {
2828
val localNumber = 20 // Local variable without shadowing
2929
return localNumber
3030
}
@@ -34,11 +34,11 @@ class VariableShadowingUnitTest {
3434
}
3535

3636
@Test
37-
fun `shadowing class member`(){
37+
fun `shadowing class member`() {
3838
class Car {
3939
val speed: Int = 100
4040

41-
fun upSpeed() : Int {
41+
fun upSpeed(): Int {
4242
val speed = speed * 2 // Shadowing class member named 'speed'
4343
return speed
4444
}
@@ -49,16 +49,16 @@ class VariableShadowingUnitTest {
4949
}
5050

5151
@Test
52-
fun `solution to avoid shadowing class member`(){
52+
fun `solution to avoid shadowing class member`() {
5353
class Car {
5454
val speed: Int = 100
5555

56-
fun newSpeed() : Int {
56+
fun newSpeed(): Int {
5757
val newSpeed = speed * 2 // Using a new variable name to avoid shadowing
5858
return newSpeed
5959
}
6060

61-
fun upSpeed() : Int {
61+
fun upSpeed(): Int {
6262
return this.speed * 2 // Use the outer speed directly with this keyword
6363
}
6464
}
@@ -69,7 +69,7 @@ class VariableShadowingUnitTest {
6969
}
7070

7171
@Test
72-
fun `local variable shadowing`(){
72+
fun `local variable shadowing`() {
7373
fun calculateTotalPrice(discount: Int) {
7474
val discount = discount + 10 // Shadowing the parameter 'discount'
7575
assertEquals(30, discount)
@@ -89,7 +89,7 @@ class VariableShadowingUnitTest {
8989
}
9090

9191
@Test
92-
fun `solution to avoid local variable shadowing`(){
92+
fun `solution to avoid local variable shadowing`() {
9393
fun calculateTotalPrice(discount: Int) {
9494
val updatedDiscount = discount + 10 // Using a new variable name to avoid shadowing
9595
assertEquals(30, updatedDiscount)
@@ -109,7 +109,7 @@ class VariableShadowingUnitTest {
109109

110110

111111
@Test
112-
fun `shadowing in loop`(){
112+
fun `shadowing in loop`() {
113113
val numbers = listOf(1, 2, 3, 4, 5)
114114

115115
// shadowing in loop
@@ -119,7 +119,7 @@ class VariableShadowingUnitTest {
119119
}
120120

121121
@Test
122-
fun `solution to avoiding shadowing in loop`(){
122+
fun `solution to avoiding shadowing in loop`() {
123123
val numbers = listOf(1, 2, 3, 4, 5)
124124

125125
// avoiding shadowing in loop
@@ -130,7 +130,7 @@ class VariableShadowingUnitTest {
130130

131131

132132
@Test
133-
fun `shadowing in extension`(){
133+
fun `shadowing in extension`() {
134134
val numbers = listOf(1, 2, 3, 4, 5)
135135

136136
assertEquals(15, numbers.sum())
@@ -145,7 +145,7 @@ class VariableShadowingUnitTest {
145145
}
146146

147147
@Test
148-
fun `solution to avoiding shadowing in extension`(){
148+
fun `solution to avoiding shadowing in extension`() {
149149
val numbers = listOf(1, 2, 3, 4, 5)
150150

151151
// in extension
@@ -165,7 +165,7 @@ class VariableShadowingUnitTest {
165165

166166

167167
@Test
168-
fun `shadowing in lambda`(){
168+
fun `shadowing in lambda`() {
169169
val numbers = listOf(1, 2, 3, 4, 5)
170170

171171
var sum = 0
@@ -177,13 +177,13 @@ class VariableShadowingUnitTest {
177177

178178
assertEquals(0, sum)
179179

180-
val lambda = { number : Int ->
180+
val lambda = { number: Int ->
181181
val number = 1 // Local variable in lambda
182182
}
183183
}
184184

185185
@Test
186-
fun `solution to avoiding shadowing in lambda`(){
186+
fun `solution to avoiding shadowing in lambda`() {
187187
val numbers = listOf(1, 2, 3, 4, 5)
188188

189189
// in lambda

0 commit comments

Comments
 (0)