Skip to content

Masenko_V/Homework_1#91

Open
Vp-Ma wants to merge 3 commits intoAndroid-Developer-Basic:masterfrom
Vp-Ma:master
Open

Masenko_V/Homework_1#91
Vp-Ma wants to merge 3 commits intoAndroid-Developer-Basic:masterfrom
Vp-Ma:master

Conversation

@Vp-Ma
Copy link

@Vp-Ma Vp-Ma commented Aug 14, 2025

No description provided.

break
}
}
if( isTarget ) break
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vp-Ma, тут можно воспользоваться break с меткой, если уж идти по пути с break и без раннего выхода

result[0] = i
result[1] = j
isTarget = true
break
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vp-Ma , проще, мне кажется, использовать конструкцию return intArrayOf(i, j) и сэкономить на предварительном создании массива и флажке

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переделал.

numbers[i] = Random.nextInt(0, 25)
}
for(i in 0..n-1){
if( numbers[i] == 0){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vp-Ma, попробуйте оператор when. Это стильно, модно и молодежно:

result[i] = when {
        i == 0 || (i % 3 == 0 && i % 5 == 0) -> "FizzBuzz"
        i % 3 == 0 -> "Fizz"
        i % 5 == 0 -> "Buzz"
        else -> i.toString()
    }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Попробовал. Получилось лучше. Спасибо.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants