Skip to content

Commit bdacc59

Browse files
committed
Convert an if used for early return into a guard
`guard` is better for early return because the compiler enforces calling `return`.
1 parent 71cf5bd commit bdacc59

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

WordPress/Classes/ViewRelated/Me/App Settings/App Icons/AppIconListViewModel.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ final class AppIconListViewModel: AppIconListViewModelType {
3939
.sorted(by: sortWithPriority(toItemsWithPrefix: AppIcon.defaultIconName))
4040
let legacyIcons = {
4141
let icons = allIcons.filter({ $0.isLegacy == true })
42-
if let legacyIconName = AppIcon.defaultLegacyIconName {
43-
return icons.sorted(by: sortWithPriority(toItemsWithPrefix: legacyIconName))
42+
43+
guard let legacyIconName = AppIcon.defaultLegacyIconName else {
44+
return icons
4445
}
45-
return icons
46+
47+
return icons.sorted(by: sortWithPriority(toItemsWithPrefix: legacyIconName))
4648
}()
4749

4850
// Set icons

0 commit comments

Comments
 (0)