Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Masenko_V/Homework_1#91

Open
Vp-Ma wants to merge 3 commits intoAndroid-Developer-Basic:masterAndroid-Developer-Basic/homework01:masterfrom
Vp-Ma:masterVp-Ma/homework01:masterCopy head branch name to clipboard
Open

Masenko_V/Homework_1#91
Vp-Ma wants to merge 3 commits intoAndroid-Developer-Basic:masterAndroid-Developer-Basic/homework01:masterfrom
Vp-Ma:masterVp-Ma/homework01:masterCopy head branch name to clipboard

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.