feat(collect!): collected! and tests implemented#27
Open
ddrkt wants to merge 2 commits intommcs-ruby:developfrom
Open
feat(collect!): collected! and tests implemented#27ddrkt wants to merge 2 commits intommcs-ruby:developfrom
ddrkt wants to merge 2 commits intommcs-ruby:developfrom
Conversation
RobolabGs2
requested changes
Nov 4, 2019
|
|
||
| def test_collect | ||
| m1 = Matrix[[1, 2], [3, 4]] | ||
| assert_equal m1.collect { |el| el.join(',') }, ["1.0,2.0", "3.0,4.0"] |
Member
There was a problem hiding this comment.
- There are usually first - expected value, second - actual in asserts.
- Standard matrix shows a different behavior:
irb(main):001:0> require 'matrix'
=> true
irb(main):002:0> m = Matrix[[1, 2], [3, 4]]
=> Matrix[[1, 2], [3, 4]]
irb(main):003:0> m.collect{ |e| e.join(',') }
Traceback (most recent call last):
15: from C:/Ruby26-x64/bin/irb.cmd:31:in `<main>'
14: from C:/Ruby26-x64/bin/irb.cmd:31:in `load'
13: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
12: from (irb):3
11: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:472:in `collect'
10: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:491:in `collect!'
9: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:583:in `each_with_index'
8: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:583:in `each_with_index'
7: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:583:in `each'
6: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:584:in `block in each_with_index'
5: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:584:in `each_with_index'
4: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:584:in `each'
3: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:585:in `block (2 levels) in each_with_index'
2: from C:/Ruby26-x64/lib/ruby/2.6.0/matrix.rb:491:in `block in collect!'
1: from (irb):3:in `block in irb_binding'
NoMethodError (undefined method `join' for 1:Integer)
irb(main):004:0> m.collect{ |e| e+1 }
=> Matrix[[2, 3], [4, 5]]
Member
|
It would be nice if you make also parameter
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.