Minor comment around the one example...
hands.flat_map(&:cards).map(&:to_s).join(', ') # => "S2, S3, S4, S3, S4, S5, S4, S5"
#join (doc) calls #to_s on the object, so that extra map is not useful.
#join
#to_s
irb(main):001:0> [:a, :b, :c].join(',') => "a,b,c"
True, and easy to forget it does that. It also flattens collections:
[[1], 2, 3, [[[4, 5], 6], 7]].join(', ') # => "1, 2, 3, 4, 5, 6, 7"
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Minor comment around the one example...
#join
(doc) calls#to_s
on the object, so that extra map is not useful.True, and easy to forget it does that. It also flattens collections: