Skip to content

Commit

Permalink
Add 'return' statements
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed committed Apr 21, 2024
1 parent d23ce15 commit 6336fb8
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions Paralayout/ViewDistributionBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,70 +23,70 @@ public struct ViewDistributionBuilder {
// Build expressions, which are turned into partial results.

public static func buildExpression(_ component: ViewDistributionSpecifying) -> [ViewDistributionSpecifying] {
[component]
return [component]
}
public static func buildExpression(_ component: CGFloat) -> [ViewDistributionSpecifying] {
[ViewDistributionItem.fixed(component)]
return [ViewDistributionItem.fixed(component)]
}
public static func buildExpression(_ component: Double) -> [ViewDistributionSpecifying] {
[ViewDistributionItem.fixed(component)]
return [ViewDistributionItem.fixed(component)]
}
public static func buildExpression(_ component: Int) -> [ViewDistributionSpecifying] {
[ViewDistributionItem.fixed(CGFloat(component))]
return [ViewDistributionItem.fixed(CGFloat(component))]
}
public static func buildExpression(_ component: [ViewDistributionSpecifying?]) -> [ViewDistributionSpecifying] {
component.compactMap { $0 }
return component.compactMap { $0 }
}
public static func buildExpression(_ component: [ViewDistributionSpecifying]) -> [ViewDistributionSpecifying] {
component
return component
}
public static func buildExpression(_ component: ViewDistributionSpecifying?) -> [ViewDistributionSpecifying] {
[component].compactMap { $0 }
return [component].compactMap { $0 }
}

// Build partial results, which accumulate.

public static func buildPartialBlock(first: ViewDistributionSpecifying) -> [ViewDistributionSpecifying] {
[first]
return [first]
}
public static func buildPartialBlock(first: [ViewDistributionSpecifying]) -> [ViewDistributionSpecifying] {
first
return first
}
public static func buildPartialBlock(accumulated: ViewDistributionSpecifying, next: ViewDistributionSpecifying) -> [ViewDistributionSpecifying] {
[accumulated, next]
return [accumulated, next]
}
public static func buildPartialBlock(accumulated: ViewDistributionSpecifying, next: [ViewDistributionSpecifying]) -> [ViewDistributionSpecifying] {
[accumulated] + next
return [accumulated] + next
}
public static func buildPartialBlock(accumulated: [ViewDistributionSpecifying], next: ViewDistributionSpecifying) -> [ViewDistributionSpecifying] {
accumulated + [next]
return accumulated + [next]
}
public static func buildPartialBlock(accumulated: [ViewDistributionSpecifying], next: [ViewDistributionSpecifying]) -> [ViewDistributionSpecifying] {
accumulated + next
return accumulated + next
}

// Build if statements

public static func buildOptional(_ component: [ViewDistributionSpecifying]?) -> [ViewDistributionSpecifying] {
component ?? []
return component ?? []
}
public static func buildOptional(_ component: [ViewDistributionSpecifying]) -> [ViewDistributionSpecifying] {
component
return component
}

// Build if-else and switch statements

public static func buildEither(first component: [ViewDistributionSpecifying]) -> [ViewDistributionSpecifying] {
component
return component
}
public static func buildEither(second component: [ViewDistributionSpecifying]) -> [ViewDistributionSpecifying] {
component
return component
}

// Build the blocks that turn into results.

public static func buildBlock(_ components: [ViewDistributionSpecifying]...) -> [ViewDistributionSpecifying] {
components.flatMap { $0 }
return components.flatMap { $0 }
}
}
#endif

0 comments on commit 6336fb8

Please sign in to comment.