Skip to content

Use forEach instead of map method in example #1981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class MosaicCollectionViewLayout: UICollectionViewFlowLayout {
let columnIndex: Int = self._shortestColumnIndexInSection(section: section)
let indexPath = IndexPath(item: idx, section: section)

let itemSize = self._itemSizeAtIndexPath(indexPath: indexPath);
let itemSize = self._itemSizeAtIndexPath(indexPath: indexPath)
let xOffset = _sectionInset.left + (columnWidth + columnSpacing) * CGFloat(columnIndex)
let yOffset = _columnHeights![section][columnIndex]

Expand Down Expand Up @@ -136,14 +136,14 @@ class MosaicCollectionViewLayout: UICollectionViewFlowLayout {

override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
if (!(self.collectionView?.bounds.size.equalTo(newBounds.size))!) {
return true;
return true
}
return false;
return false
}

func _widthForSection (section: Int) -> CGFloat
{
return self.collectionView!.bounds.size.width - _sectionInset.left - _sectionInset.right;
return self.collectionView!.bounds.size.width - _sectionInset.left - _sectionInset.right
}

func _columnWidthForSection(section: Int) -> CGFloat
Expand Down Expand Up @@ -179,11 +179,11 @@ class MosaicCollectionViewLayout: UICollectionViewFlowLayout {

func _tallestColumnIndexInSection(section: Int) -> Int
{
var index: Int = 0;
var tallestHeight: CGFloat = 0;
_ = _columnHeights?[section].enumerated().map { (idx,height) in
var index: Int = 0
var tallestHeight: CGFloat = 0
_columnHeights?[section].enumerated().forEach { (idx,height) in
if (height > tallestHeight) {
index = idx;
index = idx
tallestHeight = height
}
}
Expand All @@ -192,11 +192,11 @@ class MosaicCollectionViewLayout: UICollectionViewFlowLayout {

func _shortestColumnIndexInSection(section: Int) -> Int
{
var index: Int = 0;
var index: Int = 0
var shortestHeight: CGFloat = CGFloat.greatestFiniteMagnitude
_ = _columnHeights?[section].enumerated().map { (idx,height) in
_columnHeights?[section].enumerated().forEach { (idx,height) in
if (height < shortestHeight) {
index = idx;
index = idx
shortestHeight = height
}
}
Expand Down Expand Up @@ -241,6 +241,6 @@ class MosaicCollectionViewLayoutInspector: NSObject, ASCollectionViewLayoutInspe
}

func scrollableDirections() -> ASScrollDirection {
return ASScrollDirectionVerticalDirections;
return ASScrollDirectionVerticalDirections
}
}