Phil Pirozhkov

Results 566 comments of Phil Pirozhkov

In my book, there's only excuses for using `&method`. It's when it's either hard to come up with clear parameter names: ```ruby chaos = ['A', -1, nil, {a: 1}] chaos.map...

```ruby chaos.map { normalize(_1) } ``` You have to specify the number of arguments to pass. As you can see in the second example there can be either two or...

My bad, I've missed the "to iterators" part of the title of this discussion. Should we consider `.with_index`/`.with_object`/`inject` when talking about `&method`? `max`/`min`/`sort`? `slice_when`/`chunk_while`? `zip`? Chained `chunk`? Sorry for cleverly...

RuboCop discussions aside, I believe the Guide can be improved: 1. ~multi-line chaining is always ugly~ ```ruby # not so ugly expect { filter_applies?(:foo, lambda { |a,b,c| true }, example_metadata)...

`drop`/`take` should definitely be used more often. WDYT of > Use `take` to get the first few elements of an Array ```ruby # bad cards[0..2] cards[0, 3] cards.slice(0..3) # good...

Considering that `nil.to_a` is a `[]`, `Array#[]`'s disadvantage is not that critical.

To add to this discussion, `drop` and `take` are not implemented for String, while `slice` and `[]` are.

Should the following change do it? ```diff - Avoid `self` where not required. + Avoid calling methods on explicit `self` where not required. + # ok - `self`'s value is...

It indeed looks confusing. It was originally introduced as a bad example, see https://github.com/rubocop/ruby-style-guide/commit/4240682b0a80f0ec4a26e47c5d60cec6af51ade5#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R961 This is how bad turned good https://github.com/rubocop/ruby-style-guide/commit/3a20519560b89b568354b5f7535d67a57a9241a4 Would you like to add a brief explanation to...

In either case, I hope we'll settle on an agreement to put all definitions of methods/attributes/constants in `public` `protected` `private` order.