Skip to content
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

Each_with_index #36

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Each_with_index #36

wants to merge 4 commits into from

Conversation

labpak
Copy link
Contributor

@labpak labpak commented Nov 16, 2019

No description provided.


def each_diagonal(&block)
(0...[row_count, column_count].min).each do |i|
block[i, i]
Copy link
Member

Choose a reason for hiding this comment

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

If you don't pass a block anywhere, you should use yield

lib/matrix/matrix.rb Show resolved Hide resolved
lib/matrix/matrix.rb Show resolved Hide resolved

def each_all(&block)
Copy link
Member

Choose a reason for hiding this comment

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

This methods don't return items of the matrix -> they aren't each.
I think, that they can be extracted into a special module (may be named Utils or TraversalSequence), if row_count and column_count put in parameters.

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