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

add odd? and even? to the loop tag #232

Merged
merged 2 commits into from
May 24, 2024

Conversation

kates
Copy link
Contributor

@kates kates commented May 23, 2024

Used modulo 2 to check for "even-ness". Zero is considered as even.

#201

Comment on lines 40 to 46
def odd?
!even?
end

def even?
@index % 2 == 0
end
Copy link
Member

Choose a reason for hiding this comment

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

Why not use the existing #odd? and #even? methods?

Suggested change
def odd?
!even?
end
def even?
@index % 2 == 0
end
def odd?
@index.odd?
end
def even?
@index.even?
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoa!! I haven't thought about it. Thanks @ellmetha. I'll make the change.

Comment on lines +111 to +112
loop.index = 2
loop.odd?.should eq false
Copy link
Member

Choose a reason for hiding this comment

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

I would expect this to be in another spec example (eg. returns false if the index is not odd).

Comment on lines +125 to +126
loop.index = 1
loop.even?.should eq false
Copy link
Member

Choose a reason for hiding this comment

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

Same remark here: this could be in its own spec example (returns false if the index is not even).

@ellmetha
Copy link
Member

Thanks for adding this!

@ellmetha ellmetha merged commit d82515a into martenframework:main May 24, 2024
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants